Title: [90281] trunk
- Revision
- 90281
- Author
- mih...@chromium.org
- Date
- 2011-07-01 15:02:44 -0700 (Fri, 01 Jul 2011)
Log Message
2011-07-01 Mihai Parparita <mih...@chromium.org>
Reviewed by Darin Fisher.
location.replace with a hash change does not update the history entry
https://bugs.webkit.org/show_bug.cgi?id=63777
* fast/history/location-replace-hash-expected.txt: Added.
* fast/history/location-replace-hash.html: Added.
* fast/history/resources/location-replace-hash-1.html: Added.
* fast/history/resources/location-replace-hash-2.html: Added.
2011-07-01 Mihai Parparita <mih...@chromium.org>
Reviewed by Darin Fisher.
location.replace with a hash change does not update the history entry
https://bugs.webkit.org/show_bug.cgi?id=63777
location.replace('#foo') would not update the HistoryItem with the
new URL, thus navigating back to the page would use the previous
URL, even though it had been replaced. Make
HistoryController::updateForSameDocumentNavigation mirror
HistoryController::replaceState.
Test: fast/history/location-replace-hash.html
* loader/HistoryController.cpp:
(WebCore::HistoryController::updateForSameDocumentNavigation):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (90280 => 90281)
--- trunk/LayoutTests/ChangeLog 2011-07-01 22:01:12 UTC (rev 90280)
+++ trunk/LayoutTests/ChangeLog 2011-07-01 22:02:44 UTC (rev 90281)
@@ -1,3 +1,15 @@
+2011-07-01 Mihai Parparita <mih...@chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ location.replace with a hash change does not update the history entry
+ https://bugs.webkit.org/show_bug.cgi?id=63777
+
+ * fast/history/location-replace-hash-expected.txt: Added.
+ * fast/history/location-replace-hash.html: Added.
+ * fast/history/resources/location-replace-hash-1.html: Added.
+ * fast/history/resources/location-replace-hash-2.html: Added.
+
2011-07-01 Ryosuke Niwa <rn...@webkit.org>
Fix expected results after r90275. I checked in Mac-specific results for these tests.
Added: trunk/LayoutTests/fast/history/location-replace-hash-expected.txt (0 => 90281)
--- trunk/LayoutTests/fast/history/location-replace-hash-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/history/location-replace-hash-expected.txt 2011-07-01 22:02:44 UTC (rev 90281)
@@ -0,0 +1,19 @@
+main frame - has 1 onunload handler(s)
+main frame - has 1 onunload handler(s)
+main frame - has 1 onunload handler(s)
+Tests that using location.replace to update the hash of a page preserves it when navigating back to it.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS currentPageId is 1
+PASS currentPageId is 1
+PASS testWindow.location.hash is "#foo"
+PASS currentPageId is 2
+PASS currentPageId is 1
+PASS testWindow.location.hash is "#foo"
+PASS Complete: navigated through all the states
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/history/location-replace-hash.html (0 => 90281)
--- trunk/LayoutTests/fast/history/location-replace-hash.html (rev 0)
+++ trunk/LayoutTests/fast/history/location-replace-hash.html 2011-07-01 22:02:44 UTC (rev 90281)
@@ -0,0 +1,70 @@
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<pre id="console"></pre>
+<script>
+description('Tests that using location.replace to update the hash of a page preserves it when navigating back to it.');
+
+jsTestIsAsync = true;
+
+var testWindow;
+
+_onload_ = function()
+{
+ if (window.layoutTestController) {
+ layoutTestController.setCanOpenWindows();
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ testWindow = window.open('resources/location-replace-hash-1.html');
+ if (!testWindow)
+ testFailed('Could not open test window');
+}
+
+var currentState = 0;
+var currentPageId;
+
+function onTestWindowNavigation(pageId)
+{
+ // The page ID is put in a global so that the eval() inside of shouldBe can
+ // see it
+ currentPageId = pageId;
+ currentState++;
+
+ switch (currentState) {
+ case 1:
+ shouldBe('currentPageId', '1');
+ testWindow.location.replace('#foo');
+ break;
+ case 2:
+ shouldBe('currentPageId', '1');
+ shouldBe('testWindow.location.hash', '"#foo"');
+ testWindow.location = 'location-replace-hash-2.html';
+ break;
+ case 3:
+ shouldBe('currentPageId', '2');
+ testWindow.history.back();
+ break;
+ case 4:
+ shouldBe('currentPageId', '1');
+ shouldBe('testWindow.location.hash', '"#foo"');
+ break;
+ default:
+ testFailed('Should not be in state ' + currentState);
+ break;
+ }
+
+ if (currentState == 4) {
+ testPassed('Complete: navigated through all the states');
+ finishJSTest();
+ }
+}
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
Added: trunk/LayoutTests/fast/history/resources/location-replace-hash-1.html (0 => 90281)
--- trunk/LayoutTests/fast/history/resources/location-replace-hash-1.html (rev 0)
+++ trunk/LayoutTests/fast/history/resources/location-replace-hash-1.html 2011-07-01 22:02:44 UTC (rev 90281)
@@ -0,0 +1 @@
+<body _onload_="opener.onTestWindowNavigation(1)" _onhashchange_="opener.onTestWindowNavigation(1)" _onunload_=""></body>
Added: trunk/LayoutTests/fast/history/resources/location-replace-hash-2.html (0 => 90281)
--- trunk/LayoutTests/fast/history/resources/location-replace-hash-2.html (rev 0)
+++ trunk/LayoutTests/fast/history/resources/location-replace-hash-2.html 2011-07-01 22:02:44 UTC (rev 90281)
@@ -0,0 +1 @@
+<body _onload_="opener.onTestWindowNavigation(2)" _onhashchange_="opener.onTestWindowNavigation(2)" _onunload_=""></body>
Modified: trunk/Source/WebCore/ChangeLog (90280 => 90281)
--- trunk/Source/WebCore/ChangeLog 2011-07-01 22:01:12 UTC (rev 90280)
+++ trunk/Source/WebCore/ChangeLog 2011-07-01 22:02:44 UTC (rev 90281)
@@ -1,3 +1,21 @@
+2011-07-01 Mihai Parparita <mih...@chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ location.replace with a hash change does not update the history entry
+ https://bugs.webkit.org/show_bug.cgi?id=63777
+
+ location.replace('#foo') would not update the HistoryItem with the
+ new URL, thus navigating back to the page would use the previous
+ URL, even though it had been replaced. Make
+ HistoryController::updateForSameDocumentNavigation mirror
+ HistoryController::replaceState.
+
+ Test: fast/history/location-replace-hash.html
+
+ * loader/HistoryController.cpp:
+ (WebCore::HistoryController::updateForSameDocumentNavigation):
+
2011-07-01 Ryosuke Niwa <rn...@webkit.org>
Reviewed by Ojan Vafai.
Modified: trunk/Source/WebCore/loader/HistoryController.cpp (90280 => 90281)
--- trunk/Source/WebCore/loader/HistoryController.cpp 2011-07-01 22:01:12 UTC (rev 90280)
+++ trunk/Source/WebCore/loader/HistoryController.cpp 2011-07-01 22:02:44 UTC (rev 90281)
@@ -510,6 +510,11 @@
addVisitedLink(page, m_frame->document()->url());
page->mainFrame()->loader()->history()->recursiveUpdateForSameDocumentNavigation();
+
+ if (m_currentItem) {
+ m_currentItem->setURL(m_frame->document()->url());
+ m_frame->loader()->client()->updateGlobalHistory();
+ }
}
void HistoryController::recursiveUpdateForSameDocumentNavigation()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes