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

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

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

HtmlUnit - Dev mailing list
Revision: 14648
          http://sourceforge.net/p/htmlunit/code/14648
Author:   rbri
Date:     2017-07-10 06:45:37 +0000 (Mon, 10 Jul 2017)
Log Message:
-----------
fix ClassCastException when calculating offsetHeight
Issue 1899

Modified Paths:
--------------
    trunk/htmlunit/src/changes/changes.xml
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java

Modified: trunk/htmlunit/src/changes/changes.xml
===================================================================
--- trunk/htmlunit/src/changes/changes.xml 2017-07-07 08:35:55 UTC (rev 14647)
+++ trunk/htmlunit/src/changes/changes.xml 2017-07-10 06:45:37 UTC (rev 14648)
@@ -8,6 +8,9 @@
 
     <body>
         <release version="2.28" date="???" description="Bugfixes">
+            <action type="fix" dev="rbri" issue="1899" due-to="Christian Rösch">
+                JavaScript: fix ClassCastException when calculating offsetHeight.
+            </action>
             <action type="fix" dev="rbri">
                 Take care of label elements during event bubbling; they have to trigger a click event for the associated element.
             </action>

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2017-07-07 08:35:55 UTC (rev 14647)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2017-07-10 06:45:37 UTC (rev 14648)
@@ -1386,7 +1386,7 @@
                 boolean prevHadComputedTop = false;
                 while (prev != null && !prevHadComputedTop) {
                     if (prev instanceof HtmlElement) {
-                        final HTMLElement e = (HTMLElement) ((HtmlElement) prev).getScriptableObject();
+                        final Element e = prev.getScriptableObject();
                         final ComputedCSSStyleDeclaration style = e.getWindow().getComputedStyle(e, null);
                         int prevTop = 0;
                         if (style.top_ == null) {

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2017-07-07 08:35:55 UTC (rev 14647)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2017-07-10 06:45:37 UTC (rev 14648)
@@ -2102,4 +2102,22 @@
               + "</body></html>";
         loadPageWithAlerts2(html);
     }
+
+    /**
+     * @throws Exception if an error occurs
+     */
+    @Test
+    @Alerts("true")
+    public void calculateContentHeightAfterSVG() throws Exception {
+        final String html =
+                "<html><body>\n"
+                    + "<svg/>\n"
+                    + "<img />\n"
+                    + "<textarea id='myTextarea' cols='120' rows='20'></textarea>\n"
+                    + "<script>\n"
+                    + "  alert(document.body.offsetHeight > 10);\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