[HtmlUnit] SVN: [14139] 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: [14139] trunk/htmlunit/src

asashour-2
Revision: 14139
          http://sourceforge.net/p/htmlunit/code/14139
Author:   asashour
Date:     2017-04-20 09:14:37 +0000 (Thu, 20 Apr 2017)
Log Message:
-----------
Fix build

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMImplementationTest.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2017-04-20 06:46:04 UTC (rev 14138)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2017-04-20 09:14:37 UTC (rev 14139)
@@ -395,6 +395,7 @@
 
         /** Did the snippet tried to overwrite the start node? */
         private boolean snippetStartNodeOverwritten_;
+        private final int initialSize_;
         private DomNode currentNode_;
         private StringBuilder characters_;
         private HeadParsed headParsed_ = HeadParsed.NO;
@@ -467,6 +468,7 @@
             catch (final SAXException e) {
                 throw new ObjectInstantiationException("unable to create HTML parser", e);
             }
+            initialSize_ = stack_.size();
         }
 
         /**
@@ -757,8 +759,7 @@
                 if ("html".equals(tagLower) || "body".equals(tagLower)) {
                     return;
                 }
-                // stack_ size is 4 for snippet
-                if (stack_.size() < 5) {
+                if (stack_.size() == initialSize_) {
                     snippetStartNodeOverwritten_ = true;
                     return;
                 }

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMImplementationTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMImplementationTest.java 2017-04-20 06:46:04 UTC (rev 14138)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMImplementationTest.java 2017-04-20 09:14:37 UTC (rev 14139)
@@ -410,10 +410,6 @@
                 + "  <title>foo</title>\n"
                 + "  <script>\n"
                 + "  function test() {\n"
-                + "    if (!document.implementation.createHTMLDocument) {\n"
-                + "      alert('createHTMLDocument not available'); return;\n"
-                + "    }\n"
-
                 + "    try {\n"
                 + "      var doc = document.implementation.createHTMLDocument();\n"
                 + "      alert(doc);\n"
@@ -440,10 +436,6 @@
                 + "  <title>foo</title>\n"
                 + "  <script>\n"
                 + "  function test() {\n"
-                + "    if (!document.implementation.createHTMLDocument) {\n"
-                + "      alert('createHTMLDocument not available'); return;\n"
-                + "    }\n"
-
                 + "    try {\n"
                 + "      var doc = document.implementation.createHTMLDocument('newdoctitle');\n"
                 + "      alert(doc);\n"
@@ -470,10 +462,6 @@
                 + "  <title>foo</title>\n"
                 + "  <script>\n"
                 + "  function test() {\n"
-                + "    if (!document.implementation.createHTMLDocument) {\n"
-                + "      alert('createHTMLDocument not available'); return;\n"
-                + "    }\n"
-
                 + "    try {\n"
                 + "      var doc = document.implementation.createHTMLDocument('');\n"
                 + "      alert(doc);\n"
@@ -500,10 +488,6 @@
                 + "  <title>foo</title>\n"
                 + "  <script>\n"
                 + "  function test() {\n"
-                + "    if (!document.implementation.createHTMLDocument) {\n"
-                + "      alert('createHTMLDocument not available'); return;\n"
-                + "    }\n"
-
                 + "    try {\n"
                 + "      var doc = document.implementation.createHTMLDocument('');\n"
                 + "      doc.body.innerHTML = '<form></form><form></form>';\n"
@@ -530,10 +514,6 @@
                 + "  <title>foo</title>\n"
                 + "  <script>\n"
                 + "  function test() {\n"
-                + "    if (!document.implementation.createHTMLDocument) {\n"
-                + "      alert('createHTMLDocument not available'); return;\n"
-                + "    }\n"
-
                 + "    try {\n"
                 + "      var doc = document.implementation.createHTMLDocument('');\n"
                 + "      var p = doc.createElement('p');\n"
@@ -566,10 +546,6 @@
                 + "  <title>foo</title>\n"
                 + "  <script>\n"
                 + "  function test() {\n"
-                + "    if (!document.implementation.createHTMLDocument) {\n"
-                + "      alert('createHTMLDocument not available'); return;\n"
-                + "    }\n"
-
                 + "    try {\n"
                 + "      var doc = document.implementation.createHTMLDocument();\n"
                 + "      alert(doc.documentElement.outerHTML);\n"

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2017-04-20 06:46:04 UTC (rev 14138)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2017-04-20 09:14:37 UTC (rev 14139)
@@ -4675,7 +4675,7 @@
      * @throws Exception if the test fails
      */
     @Test
-    @Alerts({"<select id=\"myId\"><option>Two</option></select>"})
+    @Alerts("<select id=\"myId\"><option>Two</option></select>")
     public void innerHTML() throws Exception {
         final String html =
             HtmlPageTest.STANDARDS_MODE_PREFIX_
@@ -4697,4 +4697,29 @@
         loadPageWithAlerts2(html);
     }
 
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    @Alerts("1")
+    public void innerHTMLGetElementsByTagName() throws Exception {
+        final String html =
+            HtmlPageTest.STANDARDS_MODE_PREFIX_
+            + "<html>\n"
+            + "<head>\n"
+            + "  <script>\n"
+            + "    function test() {\n"
+            + "      var div = document.createElement('div');\n"
+            + "      div.innerHTML = \"<table></table><a href='/a'>a</a>\";\n"
+            + "      alert(div.getElementsByTagName('a').length);\n"
+            + "    }\n"
+            + "  </script>\n"
+            + "</head>\n"
+            + "<body onload='test()'>\n"
+            + "</body>\n"
+            + "</html>";
+
+        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...