[HtmlUnit] SVN: [14461] trunk/htmlunit

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: [14461] trunk/htmlunit

rbri
Revision: 14461
          http://sourceforge.net/p/htmlunit/code/14461
Author:   rbri
Date:     2017-05-17 19:07:31 +0000 (Wed, 17 May 2017)
Log Message:
-----------
avoid CCE in innerText when the element contains a SvgElement

Issue 1883

Modified Paths:
--------------
    trunk/htmlunit/pom.xml
    trunk/htmlunit/src/changes/changes.xml
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElementTest.java

Modified: trunk/htmlunit/pom.xml
===================================================================
--- trunk/htmlunit/pom.xml 2017-05-17 17:16:23 UTC (rev 14460)
+++ trunk/htmlunit/pom.xml 2017-05-17 19:07:31 UTC (rev 14461)
@@ -783,6 +783,9 @@
         <contributor>
             <name>Leszek Hoppe</name>
         </contributor>
+        <contributor>
+            <name>Natasha Lazarova</name>
+        </contributor>
     </contributors>
     <dependencies>
         <dependency>

Modified: trunk/htmlunit/src/changes/changes.xml
===================================================================
--- trunk/htmlunit/src/changes/changes.xml 2017-05-17 17:16:23 UTC (rev 14460)
+++ trunk/htmlunit/src/changes/changes.xml 2017-05-17 19:07:31 UTC (rev 14461)
@@ -7,7 +7,10 @@
     </properties>
 
     <body>
-        <release version="2.27" date="???" description="GAE broken, Bugfixes">
+        <release version="2.27" date="???" description="GAE broken, FF52, Bugfixes">
+            <action type="fix" dev="rbri" issue="1883">
+                Avoid CCE in innerText when the element contains a SvgElement.
+            </action>
             <action type="fix" dev="rbri">
                 Various fixes for javascript encoding detection.
             </action>

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2017-05-17 17:16:23 UTC (rev 14460)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2017-05-17 19:07:31 UTC (rev 14461)
@@ -72,6 +72,7 @@
 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.ProxyDomNode;
 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLScriptElement;
 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLStyleElement;
+import com.gargoylesoftware.htmlunit.svg.SvgElement;
 
 import net.sourceforge.htmlunit.corejs.javascript.BaseFunction;
 import net.sourceforge.htmlunit.corejs.javascript.Context;
@@ -1049,6 +1050,9 @@
             }
             builder.append(s);
         }
+        else if (node instanceof SvgElement) {
+            // nothing to do for the moment
+        }
         else if (html) {
             final DomElement element = (DomElement) node;
             final Element scriptObject = (Element) node.getScriptableObject();

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElementTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElementTest.java 2017-05-17 17:16:23 UTC (rev 14460)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSVGElementTest.java 2017-05-17 19:07:31 UTC (rev 14461)
@@ -27,6 +27,8 @@
  *
  * @author Ahmed Ashour
  * @author Frank Danek
+ * @author Ronald Brill
+ * @author Natasha Lazarova
  */
 @RunWith(BrowserRunner.class)
 public class SVGSVGElementTest extends WebDriverTestCase {
@@ -49,4 +51,40 @@
 
         loadPageWithAlerts2(html);
     }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
+    @Alerts("undefined")
+    public void getInnerTextOfSvg() throws Exception {
+        final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+                + "<html><body>\n"
+                + "  <svg xmlns='http://www.w3.org/2000/svg' id='myId' version='1.1'></svg>\n"
+                + "  <script>\n"
+                + "    var svg =  document.getElementById('myId');\n"
+                + "    alert(svg.innerText);\n"
+                + "  </script>\n"
+                + "</body></html>";
+
+        loadPageWithAlerts2(html);
+    }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    @Alerts("")
+    public void getInnerTextOfElementContainingSvg() throws Exception {
+        final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+                + "<html><body>\n"
+                + "  <div id='myDivId'><svg xmlns='http://www.w3.org/2000/svg' version='1.1'></svg></div>\n"
+                + "  <script>\n"
+                + "    var div = document.getElementById('myDivId');\n"
+                + "    alert(div.innerText);\n"
+                + "  </script>\n"
+                + "</body></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...