Quantcast

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

asashour-2
Revision: 13804
          http://sourceforge.net/p/htmlunit/code/13804
Author:   asashour
Date:     2017-03-17 17:19:21 +0000 (Fri, 17 Mar 2017)
Log Message:
-----------
CSS: fix handling :target pseudo class

Modified Paths:
--------------
    trunk/htmlunit/pom.xml
    trunk/htmlunit/src/changes/changes.xml
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomNode2Test.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheetTest.java

Modified: trunk/htmlunit/pom.xml
===================================================================
--- trunk/htmlunit/pom.xml 2017-03-17 13:05:54 UTC (rev 13803)
+++ trunk/htmlunit/pom.xml 2017-03-17 17:19:21 UTC (rev 13804)
@@ -374,6 +374,7 @@
                 <configuration>
                     <issueLinkTemplatePerSystem>
                         <features><a href="http://sourceforge.net/p/htmlunit/feature-requests/%ISSUE%">http://sourceforge.net/p/htmlunit/feature-requests/%ISSUE%</features>
+                        <htmlunitdriver><a href="https://github.com/SeleniumHQ/htmlunit-driver/issues/%ISSUE%">https://github.com/SeleniumHQ/htmlunit-driver/issues/%ISSUE%</htmlunitdriver>
                     </issueLinkTemplatePerSystem>
                 </configuration>
             </plugin>

Modified: trunk/htmlunit/src/changes/changes.xml
===================================================================
--- trunk/htmlunit/src/changes/changes.xml 2017-03-17 13:05:54 UTC (rev 13803)
+++ trunk/htmlunit/src/changes/changes.xml 2017-03-17 17:19:21 UTC (rev 13804)
@@ -8,6 +8,9 @@
 
     <body>
         <release version="2.26" date="???" description="Bugfixes">
+            <action type="fix" dev="asashour" system="htmlunitdriver" issue="46">
+                CSS: fix handling :target pseudo class.
+            </action>
             <action type="update" dev="asashour">
                 Deprecate HtmlImage.getComplete().
             </action>

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-03-17 13:05:54 UTC (rev 13803)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-03-17 17:19:21 UTC (rev 13804)
@@ -1437,10 +1437,6 @@
     @BrowserFeature(@WebBrowser(IE))
     QUERYSELECTORALL_NOT_IN_QUIRKS,
 
-    /** Indicates {@code .querySelectorAll()} supports {@code :target} condition. */
-    @BrowserFeature(@WebBrowser(CHROME))
-    QUERYSELECTORALL_NO_TARGET,
-
     /** IE throws a syntax error if a css3 pseudo selector is used on an detached node. */
     @BrowserFeature(@WebBrowser(IE))
     QUERYSELECTOR_CSS3_PSEUDO_REQUIRE_ATTACHED_NODE,

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2017-03-17 13:05:54 UTC (rev 13803)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2017-03-17 17:19:21 UTC (rev 13804)
@@ -356,6 +356,7 @@
                 final Window window = (Window) webWindow.getScriptableObject();
                 if (window != null) { // js enabled
                     window.getLocation().setHash(current.getRef());
+                    window.clearComputedStyles();
                 }
                 return (P) page;
             }

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2017-03-17 13:05:54 UTC (rev 13803)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2017-03-17 17:19:21 UTC (rev 13804)
@@ -16,7 +16,6 @@
 
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLLINK_CHECK_TYPE_FOR_STYLESHEET;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.QUERYSELECTORALL_NOT_IN_QUIRKS;
-import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.QUERYSELECTORALL_NO_TARGET;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.QUERYSELECTOR_CSS3_PSEUDO_REQUIRE_ATTACHED_NODE;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.STYLESHEET_HREF_EMPTY_IS_NULL;
 import static com.gargoylesoftware.htmlunit.html.DomElement.ATTRIBUTE_NOT_DEFINED;
@@ -793,9 +792,6 @@
                 return isEmpty(element);
 
             case "target":
-                if (browserVersion.hasFeature(QUERYSELECTORALL_NO_TARGET)) {
-                    return false;
-                }
                 final String ref = element.getPage().getUrl().getRef();
                 return StringUtils.isNotBlank(ref) && ref.equals(element.getId());
 

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2017-03-17 13:05:54 UTC (rev 13803)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2017-03-17 17:19:21 UTC (rev 13804)
@@ -1826,7 +1826,7 @@
             for (final DomNode domNode : getDomNodeOrDie().querySelectorAll(selectors)) {
                 nodes.add(domNode.getScriptableObject());
             }
-            return  NodeList.staticNodeList(this, nodes);
+            return NodeList.staticNodeList(this, nodes);
         }
         catch (final CSSException e) {
             throw Context.reportRuntimeError("An invalid or illegal selector was specified (selector: '"

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomNode2Test.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomNode2Test.java 2017-03-17 13:05:54 UTC (rev 13803)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomNode2Test.java 2017-03-17 17:19:21 UTC (rev 13804)
@@ -80,4 +80,5 @@
 
         loadPageWithAlerts2(html);
     }
+
 }

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheetTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheetTest.java 2017-03-17 13:05:54 UTC (rev 13803)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheetTest.java 2017-03-17 17:19:21 UTC (rev 13804)
@@ -1273,4 +1273,33 @@
 
         loadPageWithAlerts2(html);
     }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void isDisplayed() throws Exception {
+        final String html = "<!DOCTYPE html>\n"
+                + "<head>\n"
+                + "<style>\n"
+                + "  .tab div {\n"
+                + "    display: none;\n"
+                + "  }\n"
+                + "\n"
+                + "  .tab div:target {\n"
+                + "    display: block;\n"
+                + "  }\n"
+                + "</style></head><body>\n"
+                + "<div class='tab'>\n"
+                + "  <div id='anchor'>\n"
+                + "    <p>Content</p>\n"
+                + "  </div>\n"
+                + "</div>\n"
+                + "</body></html>";
+        getMockWebConnection().setDefaultResponse(html);;
+        final WebDriver webDriver = loadPage2(html);
+        assertFalse(webDriver.findElement(By.id("anchor")).isDisplayed());
+        webDriver.get(URL_FIRST + "#anchor");
+        assertTrue(webDriver.findElement(By.id("anchor")).isDisplayed());
+    }
 }


------------------------------------------------------------------------------
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...