[prev in list] [next in list] [prev in thread] [next in thread] 

List:       htmlunit-develop
Subject:    [HtmlUnit] SVN: [11687] trunk/htmlunit/src
From:       rbri () users ! sourceforge ! net
Date:       2015-12-30 10:13:00
Message-ID: E1aEDkd-0000Se-EX () sfs-ml-3 ! v29 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 11687
          http://sourceforge.net/p/htmlunit/code/11687
Author:   rbri
Date:     2015-12-30 10:13:00 +0000 (Wed, 30 Dec 2015)
Log Message:
-----------
fix form processing for urls containing anchors when simulating chrome.

Modified Paths:
--------------
    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/html/HtmlAnchor.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java
  trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java
  trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PageReloadTest.java

Modified: trunk/htmlunit/src/changes/changes.xml
===================================================================
--- trunk/htmlunit/src/changes/changes.xml	2015-12-29 20:12:53 UTC (rev 11686)
+++ trunk/htmlunit/src/changes/changes.xml	2015-12-30 10:13:00 UTC (rev 11687)
@@ -9,6 +9,9 @@
     <body>
         <release version="2.20" date="???" description="IE8 is no longer supported, \
Bugfixes">  <action type="fix" dev="rbri">
+                Fix form processing for urls containing anchors when simulating \
chrome. +            </action>
+            <action type="fix" dev="rbri">
                 Result of innerText fixed for Chrome.
             </action>
             <action type="fix" dev="rbri">

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
 ===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java	2015-12-29 \
                20:12:53 UTC (rev 11686)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java	2015-12-30 \
10:13:00 UTC (rev 11687) @@ -247,6 +247,10 @@
     @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) })
     FORMFIELD_REACHABLE_BY_ORIGINAL_NAME,
 
+    /** Form submit forces an real request also if only the hash was changed. */
+    @BrowserFeature(@WebBrowser(CHROME))
+    FORM_SUBMISSION_DOWNLOWDS_ALSO_IF_ONLY_HASH_CHANGED,
+
     /** Form submit is done without the hash part of the action url. */
     @BrowserFeature(@WebBrowser(IE))
     FORM_SUBMISSION_URL_WITHOUT_HASH,

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java	2015-12-29 \
                20:12:53 UTC (rev 11686)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java	2015-12-30 \
10:13:00 UTC (rev 11687) @@ -2000,11 +2000,12 @@
      * @param requestingWindow the window from which the request comes
      * @param target the name of the target window
      * @param request the request to perform
+     * @param checkHash if true check for hashChenage
      * @param forceLoad if true always load the request even if there is already the \
                same in the queue
      * @param description information about the origin of the request. Useful for \
                debugging.
      */
     public void download(final WebWindow requestingWindow, final String target,
-        final WebRequest request, final boolean forceLoad, final String description) \
{ +        final WebRequest request, final boolean checkHash, final boolean \
forceLoad, final String description) {  final WebWindow win = \
resolveWindow(requestingWindow, target);  final URL url = request.getUrl();
         boolean justHashJump = false;
@@ -2017,11 +2018,13 @@
                         return;
                     }
 
-                    final URL current = page.getUrl();
-                    justHashJump =
-                            HttpMethod.GET == request.getHttpMethod()
-                            && url.sameFile(current)
-                            && null != url.getRef();
+                    if (checkHash) {
+                        final URL current = page.getUrl();
+                        justHashJump =
+                                HttpMethod.GET == request.getHttpMethod()
+                                && url.sameFile(current)
+                                && null != url.getRef();
+                    }
                 }
             }
 

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java
 ===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java	2015-12-29 \
                20:12:53 UTC (rev 11686)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java	2015-12-30 \
10:13:00 UTC (rev 11687) @@ -124,7 +124,7 @@
         }
         htmlPage.getWebClient().download(htmlPage.getEnclosingWindow(),
                 htmlPage.getResolvedTarget(getTargetAttribute()),
-                webRequest, false, "Link click");
+                webRequest, true, false, "Link click");
     }
 
     /**

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java
 ===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java	2015-12-29 \
                20:12:53 UTC (rev 11686)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java	2015-12-30 \
10:13:00 UTC (rev 11687) @@ -14,6 +14,7 @@
  */
 package com.gargoylesoftware.htmlunit.html;
 
+import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.FORM_SUBMISSION_DOWNLOWDS_ALSO_IF_ONLY_HASH_CHANGED;
  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.FORM_SUBMISSION_URL_WITHOUT_HASH;
  
 import java.net.MalformedURLException;
@@ -134,7 +135,10 @@
         final String target = htmlPage.getResolvedTarget(getTargetAttribute());
 
         final WebWindow webWindow = htmlPage.getEnclosingWindow();
-        webClient.download(webWindow, target, request, false, "JS form.submit()");
+        /** Calling form.submit() twice forces double download. */
+        final boolean checkHash =
+                !webClient.getBrowserVersion().hasFeature(FORM_SUBMISSION_DOWNLOWDS_ALSO_IF_ONLY_HASH_CHANGED);
 +        webClient.download(webWindow, target, request, checkHash, false, "JS \
form.submit()");  return htmlPage;
     }
 

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java
 ===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java	2015-12-29 \
                20:12:53 UTC (rev 11686)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java	2015-12-30 \
10:13:00 UTC (rev 11687) @@ -257,7 +257,7 @@
             request.setAdditionalHeader("Referer", page.getUrl().toExternalForm());
 
             final WebWindow webWindow = getWindow().getWebWindow();
-            webWindow.getWebClient().download(webWindow, "", request, false, "JS set \
location"); +            webWindow.getWebClient().download(webWindow, "", request, \
true, false, "JS set location");  }
         catch (final MalformedURLException e) {
             LOG.error("setHref('" + newLocation + "') got MalformedURLException", \
e);

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java
 ===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java	2015-12-29 \
                20:12:53 UTC (rev 11686)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java	2015-12-30 \
10:13:00 UTC (rev 11687) @@ -16,6 +16,7 @@
 
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.FORMFIELD_REACHABLE_BY_NEW_NAMES;
  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.FORMFIELD_REACHABLE_BY_ORIGINAL_NAME;
 +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.FORM_SUBMISSION_DOWNLOWDS_ALSO_IF_ONLY_HASH_CHANGED;
  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_FORM_ACTION_EXPANDURL_IGNORE_EMPTY;
  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_FORM_DISPATCHEVENT_SUBMITS;
  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_FORM_REJECT_INVALID_ENCODING;
 @@ -360,7 +361,10 @@
             final WebRequest request = getHtmlForm().getWebRequest(null);
             final String target = page.getResolvedTarget(getTarget());
             final boolean forceDownload = \
                webClient.getBrowserVersion().hasFeature(JS_FORM_SUBMIT_FORCES_DOWNLOAD);
                
-            webClient.download(page.getEnclosingWindow(), target, request, \
forceDownload, "JS form.submit()"); +            final boolean checkHash =
+                    \
!webClient.getBrowserVersion().hasFeature(FORM_SUBMISSION_DOWNLOWDS_ALSO_IF_ONLY_HASH_CHANGED);
 +            webClient.download(page.getEnclosingWindow(),
+                        target, request, checkHash, forceDownload, "JS \
form.submit()");  }
     }
 

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PageReloadTest.java
 ===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PageReloadTest.java	2015-12-29 \
                20:12:53 UTC (rev 11686)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/PageReloadTest.java	2015-12-30 \
10:13:00 UTC (rev 11687) @@ -14,8 +14,6 @@
  */
 package com.gargoylesoftware.htmlunit;
 
-import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.CHROME;
-
 import java.net.URL;
 
 import org.junit.Test;
@@ -24,7 +22,6 @@
 import org.openqa.selenium.WebDriver;
 
 import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts;
-import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented;
 
 /**
  * Tests for page reloading in various situations.
@@ -384,7 +381,6 @@
     @Alerts(DEFAULT = "0",
             CHROME = "1",
             IE = "1")
-    @NotYetImplemented(CHROME)
     public void submitGet_url_emptyHash() throws Exception {
         openUrlAndClickById(RELOAD_URL, "submitGetEmptyHash", \
Integer.parseInt(getExpectedAlerts()[0]), PATHNAME, "");  }
@@ -404,7 +400,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR },
             CHROME = { "1", ANCHOR },
             IE = {"1", "" })
-    @NotYetImplemented(CHROME)
     public void submitGet_url_hash() throws Exception {
         openUrlAndClickById(RELOAD_URL, "submitGetHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);
@@ -427,7 +422,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR2 },
             CHROME = { "1", ANCHOR2 },
             IE = {"1", "" })
-    @NotYetImplemented(CHROME)
     public void submitGet_url_differentHash() throws Exception {
         openUrlAndClickById(RELOAD_URL, "submitGetDifferentHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);
@@ -466,7 +460,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR },
             CHROME = { "1", ANCHOR },
             IE = {"1", "" })
-    @NotYetImplemented(CHROME)
     public void submitGet_url_urlHash() throws Exception {
         openUrlAndClickById(RELOAD_URL, "submitGetUrlHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);
@@ -563,7 +556,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR },
             CHROME = { "1", ANCHOR },
             IE = {"1", "" })
-    @NotYetImplemented(CHROME)
     public void submitGet_urlHash_emptyUrl() throws Exception {
         openUrlAndClickById("http://localhost:" + PORT + "/reload.html#anchor", \
"submitGetEmpty",  Integer.parseInt(getExpectedAlerts()[0]),
@@ -588,7 +580,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR },
             CHROME = { "1", ANCHOR },
             IE = {"1", "" })
-    @NotYetImplemented(CHROME)
     public void submitGet_urlHash_hash() throws Exception {
         openUrlAndClickById(RELOAD_URL_ANCHOR, "submitGetHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);
@@ -611,7 +602,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR2 },
             CHROME = { "1", ANCHOR2 },
             IE = {"1", "" })
-    @NotYetImplemented(CHROME)
     public void submitGet_urlHash_differentHash() throws Exception {
         openUrlAndClickById(RELOAD_URL_ANCHOR, "submitGetDifferentHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);
@@ -651,7 +641,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR },
             CHROME = { "1", ANCHOR },
             IE = {"1", "" })
-    @NotYetImplemented(CHROME)
     public void submitGet_urlHash_urlHash() throws Exception {
         openUrlAndClickById(RELOAD_URL_ANCHOR, "submitGetUrlHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);
@@ -1091,7 +1080,6 @@
     @Alerts(DEFAULT = "0",
             CHROME = "1",
             IE = "1")
-    @NotYetImplemented(CHROME)
     public void jsSubmitGet_url_emptyHash() throws Exception {
         openUrlAndClickById(RELOAD_URL, "jsSubmitGetEmptyHash", \
Integer.parseInt(getExpectedAlerts()[0]), PATHNAME, "");  }
@@ -1111,7 +1099,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR },
             CHROME = { "1", ANCHOR },
             IE = { "1", "" })
-    @NotYetImplemented(CHROME)
     public void jsSubmitGet_url_hash() throws Exception {
         openUrlAndClickById(RELOAD_URL, "jsSubmitGetHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);
@@ -1134,7 +1121,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR2 },
             CHROME = { "1", ANCHOR2 },
             IE = { "1", "" })
-    @NotYetImplemented(CHROME)
     public void jsSubmitGet_url_differentHash() throws Exception {
         openUrlAndClickById(RELOAD_URL, "jsSubmitGetDifferentHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);
@@ -1173,7 +1159,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR },
             CHROME = { "1", ANCHOR },
             IE = { "1", "" })
-    @NotYetImplemented(CHROME)
     public void jsSubmitGet_url_urlHash() throws Exception {
         openUrlAndClickById(RELOAD_URL, "jsSubmitGetUrlHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);
@@ -1268,7 +1253,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR },
             CHROME = { "1", ANCHOR },
             IE = { "1", "" })
-    @NotYetImplemented(CHROME)
     public void jsSubmitGet_urlHash_emptyUrl() throws Exception {
         openUrlAndClickById("http://localhost:" + PORT + "/reload.html#anchor",
                "jsSubmitGetEmpty", Integer.parseInt(getExpectedAlerts()[0]), \
PATHNAME, getExpectedAlerts()[1]); @@ -1292,7 +1276,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR },
             CHROME = { "1", ANCHOR },
             IE = { "1", "" })
-    @NotYetImplemented(CHROME)
     public void jsSubmitGet_urlHash_hash() throws Exception {
         openUrlAndClickById(RELOAD_URL_ANCHOR, "jsSubmitGetHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);
@@ -1315,7 +1298,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR2 },
             CHROME = { "1", ANCHOR2 },
             IE = { "1", "" })
-    @NotYetImplemented(CHROME)
     public void jsSubmitGet_urlHash_differentHash() throws Exception {
         openUrlAndClickById(RELOAD_URL_ANCHOR, "jsSubmitGetDifferentHash",
                 Integer.parseInt(getExpectedAlerts()[0]), PATHNAME, \
getExpectedAlerts()[1]); @@ -1354,7 +1336,6 @@
     @Alerts(DEFAULT = { "0", ANCHOR },
             CHROME = { "1", ANCHOR },
             IE = { "1", "" })
-    @NotYetImplemented(CHROME)
     public void jsSubmitGet_urlHash_urlHash() throws Exception {
         openUrlAndClickById(RELOAD_URL_ANCHOR, "jsSubmitGetUrlHash", \
Integer.parseInt(getExpectedAlerts()[0]),  PATHNAME, getExpectedAlerts()[1]);


------------------------------------------------------------------------------
_______________________________________________
HtmlUnit-develop mailing list
HtmlUnit-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic