Title: [170404] trunk
Revision
170404
Author
mr...@apple.com
Date
2014-06-24 16:33:55 -0700 (Tue, 24 Jun 2014)

Log Message

WKContextHistoryClient::didNavigateWithNavigationData is passed incorrect URL when history.pushState is used
<https://webkit.org/b/134271> / <rdar://problem/16270167>

Reviewed by Brady Eidson.

Source/WebCore:
Tests: http/tests/globalhistory/history-delegate-pushstate.html
       http/tests/globalhistory/history-delegate-replacestate.html

* page/History.cpp:
(WebCore::History::stateObjectAdded): Call HistoryController after updating the document's URL so that the
URL will reflect the destination of the navigation when FrameLoaderClient::updateGlobalHistory is called.

LayoutTests:
* http/tests/globalhistory/history-delegate-pushstate-expected.txt: Added.
* http/tests/globalhistory/history-delegate-pushstate.html: Added.
* http/tests/globalhistory/history-delegate-replacestate-expected.txt: Added.
* http/tests/globalhistory/history-delegate-replacestate.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (170403 => 170404)


--- trunk/LayoutTests/ChangeLog	2014-06-24 23:33:03 UTC (rev 170403)
+++ trunk/LayoutTests/ChangeLog	2014-06-24 23:33:55 UTC (rev 170404)
@@ -1,3 +1,15 @@
+2014-06-24  Mark Rowe  <mr...@apple.com>
+
+        WKContextHistoryClient::didNavigateWithNavigationData is passed incorrect URL when history.pushState is used
+        <https://webkit.org/b/134271> / <rdar://problem/16270167>
+
+        Reviewed by Brady Eidson.
+
+        * http/tests/globalhistory/history-delegate-pushstate-expected.txt: Added.
+        * http/tests/globalhistory/history-delegate-pushstate.html: Added.
+        * http/tests/globalhistory/history-delegate-replacestate-expected.txt: Added.
+        * http/tests/globalhistory/history-delegate-replacestate.html: Added.
+
 2014-06-24  Yusuke Suzuki  <utatane....@gmail.com>
 
         CSS JIT: Add positionInRootFragments to SelectorFragment

Added: trunk/LayoutTests/http/tests/globalhistory/history-delegate-pushstate-expected.txt (0 => 170404)


--- trunk/LayoutTests/http/tests/globalhistory/history-delegate-pushstate-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/globalhistory/history-delegate-pushstate-expected.txt	2014-06-24 23:33:55 UTC (rev 170404)
@@ -0,0 +1,10 @@
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-pushstate.html" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-pushstate.html?1" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-pushstate.html?2" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-pushstate.html?3" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-pushstate.html?4" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-pushstate.html?5" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+This tests functionality of the history delegate related to history.pushState.

Added: trunk/LayoutTests/http/tests/globalhistory/history-delegate-pushstate.html (0 => 170404)


--- trunk/LayoutTests/http/tests/globalhistory/history-delegate-pushstate.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/globalhistory/history-delegate-pushstate.html	2014-06-24 23:33:55 UTC (rev 170404)
@@ -0,0 +1,23 @@
+<script>
+
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+    testRunner.dumpFrameLoadCallbacks();
+}
+
+var n = 0;
+function runTest() {
+    if (++n > 5) {
+        if (window.testRunner)
+            testRunner.notifyDone();
+        return;
+    }
+    history.pushState({}, 'State ' + n, 'http://127.0.0.1:8000/globalhistory/history-delegate-pushstate.html?' + n);
+    setTimeout(runTest, 10);
+}
+
+</script>
+<body _onload_="setTimeout(runTest, 10);">
+This tests functionality of the history delegate related to history.pushState.
+</body>

Added: trunk/LayoutTests/http/tests/globalhistory/history-delegate-replacestate-expected.txt (0 => 170404)


--- trunk/LayoutTests/http/tests/globalhistory/history-delegate-replacestate-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/globalhistory/history-delegate-replacestate-expected.txt	2014-06-24 23:33:55 UTC (rev 170404)
@@ -0,0 +1,10 @@
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-replacestate.html" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-replacestate.html?1" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-replacestate.html?2" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-replacestate.html?3" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-replacestate.html?4" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-replacestate.html?5" with title "" with HTTP equivalent method "GET".  The navigation was successful and was not a client redirect.
+This tests functionality of the history delegate related to history.replaceState.

Added: trunk/LayoutTests/http/tests/globalhistory/history-delegate-replacestate.html (0 => 170404)


--- trunk/LayoutTests/http/tests/globalhistory/history-delegate-replacestate.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/globalhistory/history-delegate-replacestate.html	2014-06-24 23:33:55 UTC (rev 170404)
@@ -0,0 +1,23 @@
+<script>
+
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+    testRunner.dumpFrameLoadCallbacks();
+}
+
+var n = 0;
+function runTest() {
+    if (++n > 5) {
+        if (window.testRunner)
+            testRunner.notifyDone();
+        return;
+    }
+    history.replaceState({}, 'State ' + n, 'http://127.0.0.1:8000/globalhistory/history-delegate-replacestate.html?' + n);
+    setTimeout(runTest, 10);
+}
+
+</script>
+<body _onload_="setTimeout(runTest, 10);">
+This tests functionality of the history delegate related to history.replaceState.
+</body>

Modified: trunk/Source/WebCore/ChangeLog (170403 => 170404)


--- trunk/Source/WebCore/ChangeLog	2014-06-24 23:33:03 UTC (rev 170403)
+++ trunk/Source/WebCore/ChangeLog	2014-06-24 23:33:55 UTC (rev 170404)
@@ -1,3 +1,17 @@
+2014-06-24  Mark Rowe  <mr...@apple.com>
+
+        WKContextHistoryClient::didNavigateWithNavigationData is passed incorrect URL when history.pushState is used
+        <https://webkit.org/b/134271> / <rdar://problem/16270167>
+
+        Reviewed by Brady Eidson.
+
+        Tests: http/tests/globalhistory/history-delegate-pushstate.html
+               http/tests/globalhistory/history-delegate-replacestate.html
+
+        * page/History.cpp:
+        (WebCore::History::stateObjectAdded): Call HistoryController after updating the document's URL so that the
+        URL will reflect the destination of the navigation when FrameLoaderClient::updateGlobalHistory is called.
+
 2014-06-24  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         advanceByCombiningCharacterSequence() can be simplified

Modified: trunk/Source/WebCore/page/History.cpp (170403 => 170404)


--- trunk/Source/WebCore/page/History.cpp	2014-06-24 23:33:03 UTC (rev 170403)
+++ trunk/Source/WebCore/page/History.cpp	2014-06-24 23:33:55 UTC (rev 170404)
@@ -147,18 +147,16 @@
         return;
     }
 
-    if (stateObjectType == StateObjectType::Push)
-        m_frame->loader().history().pushState(data, title, fullURL.string());
-    else if (stateObjectType == StateObjectType::Replace)
-        m_frame->loader().history().replaceState(data, title, fullURL.string());
-            
     if (!urlString.isEmpty())
         m_frame->document()->updateURLForPushOrReplaceState(fullURL);
 
-    if (stateObjectType == StateObjectType::Push)
+    if (stateObjectType == StateObjectType::Push) {
+        m_frame->loader().history().pushState(data, title, fullURL.string());
         m_frame->loader().client().dispatchDidPushStateWithinPage();
-    else if (stateObjectType == StateObjectType::Replace)
+    } else if (stateObjectType == StateObjectType::Replace) {
+        m_frame->loader().history().replaceState(data, title, fullURL.string());
         m_frame->loader().client().dispatchDidReplaceStateWithinPage();
+    }
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to