Quantcast

[HtmlUnit] SVN: [14418] trunk/htmlunit/src

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[HtmlUnit] SVN: [14418] trunk/htmlunit/src

asashour-2
Revision: 14418
          http://sourceforge.net/p/htmlunit/code/14418
Author:   asashour
Date:     2017-05-08 08:38:14 +0000 (Mon, 08 May 2017)
Log Message:
-----------
JavaScript: document.rootElement

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLDocumentTest.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java 2017-05-08 07:45:53 UTC (rev 14417)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java 2017-05-08 08:38:14 UTC (rev 14418)
@@ -377,6 +377,15 @@
     }
 
     /**
+     * Gets the JavaScript property {@code rootElement}.
+     * @return the root node for the document
+     */
+    @JsxGetter({CHROME, FF52, IE})
+    public Element getRootElement() {
+        return null;
+    }
+
+    /**
      * Gets the JavaScript property {@code doctype} for the document.
      * @return the DocumentType of the document
      */

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java 2017-05-08 07:45:53 UTC (rev 14417)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentTest.java 2017-05-08 08:38:14 UTC (rev 14418)
@@ -2487,4 +2487,27 @@
         loadPageWithAlerts2(html);
     }
 
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    @Alerts(DEFAULT = {"null", "null"},
+            FF45 = {"undefined", "undefined"})
+    public void rootElement() throws Exception {
+        final String html = "<html>\n"
+            + "<head>\n"
+            + "  <script>\n"
+            + "    function test() {\n"
+            + "      var xmlDocument = document.implementation.createDocument('', '', null);\n"
+            + "      alert(xmlDocument.rootElement);\n"
+            + "      alert(document.rootElement);\n"
+            + "    }\n"
+            + "  </script>\n"
+            + "</head>\n"
+            + "<body onload='test()'></body>\n"
+            + "</html>";
+
+        loadPageWithAlerts2(html);
+    }
+
 }

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLDocumentTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLDocumentTest.java 2017-05-08 07:45:53 UTC (rev 14417)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLDocumentTest.java 2017-05-08 08:38:14 UTC (rev 14418)
@@ -104,12 +104,7 @@
     /** Helper. */
     public static final String SERIALIZE_XML_DOCUMENT_TO_STRING_FUNCTION = ""
             + "  function " + SERIALIZE_XML_DOCUMENT_TO_STRING_FUNCTION_NAME + "(doc) {\n"
-            + "    if (window.XMLSerializer) {\n"
-            + "      serializer = new XMLSerializer();\n"
-            + "      return serializer.serializeToString(doc);\n"
-            + "    } else {\n"
-            + "      return doc.xml;\n"
-            + "    }\n"
+            + "    return new XMLSerializer().serializeToString(doc);\n"
             + "  }\n";
 
     /** Helper. */
@@ -965,9 +960,7 @@
             + "    ifr.onload = function() {\n"
             + "      var xml = ifr.contentWindow.document;\n"
             + "      alert(xml);\n"
-            + "      if(xml.getElementsByTagName) {\n"
-            + "        alert(xml.getElementsByTagName('status')[0].textContent);\n"
-            + "      }\n"
+            + "      alert(xml.getElementsByTagName('status')[0].textContent);\n"
             + "    };\n"
             + "    ifr.src = '" + URL_SECOND + "';\n"
             + "  }\n"
@@ -1042,15 +1035,6 @@
             + "  <div id='tester'></div>\n"
             + "</body></html>";
 
-        final String xml
-            = "<books>\n"
-            + "  <book>\n"
-            + "    <title>Immortality</title>\n"
-            + "    <author>John Smith</author>\n"
-            + "  </book>\n"
-            + "</books>";
-
-        getMockWebConnection().setResponse(URL_SECOND, xml, "text/xml");
         loadPageWithAlerts2(html);
     }
 }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Loading...