Commit f44ff465 authored by darin@chromium.org's avatar darin@chromium.org
Browse files

2011-01-19 Darin Fisher <darin@chromium.org>

        Reviewed by Mihai Parparita.

        Re-initialize the HistoryItem fully when navigating to a HistoryItem,
        or replacing a HistoryItem, results in a different URL.

        https://bugs.webkit.org/show_bug.cgi?id=49654

        This patch also forces all HistoryItems to record the post-redirect
        URL.  Previously, frames would remember the pre-redirect URL.  This is
        problematic since other members of the HistoryItem correspond to the
        post-redirect URL.

        Tests: fast/history/history-replace-updates-current-item.html
               http/tests/navigation/redirect-on-back-updates-history-item.html
               http/tests/navigation/redirect-on-reload-updates-history-item.html

        * history/HistoryItem.cpp:
        (WebCore::HistoryItem::HistoryItem):
        (WebCore::HistoryItem::reset):
        * history/HistoryItem.h:
        * loader/HistoryController.cpp:
        (WebCore::HistoryController::updateForBackForwardNavigation):
        (WebCore::HistoryController::updateForReload):
        (WebCore::HistoryController::updateForStandardLoad):
        (WebCore::HistoryController::updateForRedirectWithLockedBackForwardList):
        (WebCore::HistoryController::initializeItem):
        (WebCore::HistoryController::createItem):
        (WebCore::HistoryController::createItemTree):
        (WebCore::HistoryController::updateCurrentItem):
        * loader/HistoryController.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76205 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 470fff08
2011-01-14 Darin Fisher <darin@chromium.org>
Reviewed by Mihai Parparita.
Update expectations for existing tests that expect us to record pre-redirect
URLs for frames. We are now recording post-redirect URLs in HistoryItems.
Add new tests to confirm that we re-initialize the current HistoryItem properly
in the following cases:
1- Navigating back in history to an URL that redirects someplace else this time.
2- Reloading an URL that redirects someplace else this time.
3- Replacing the current history item with a different URL.
https://bugs.webkit.org/show_bug.cgi?id=49654
* fast/history/history-replace-updates-current-item-expected.txt: Added.
* fast/history/history-replace-updates-current-item.html: Added.
* fast/history/resources/history-replace-updates-current-item-done.html: Added.
* fast/history/resources/history-replace-updates-current-item-goback.html: Added.
* http/tests/navigation/postredirect-frames-expected.txt: Added.
* http/tests/navigation/postredirect-frames-goback1-expected.txt:
* http/tests/navigation/postredirect-frames.html:
* http/tests/navigation/redirect-on-back-updates-history-item-expected.txt: Added.
* http/tests/navigation/redirect-on-back-updates-history-item.html: Added.
* http/tests/navigation/redirect-on-reload-updates-history-item-expected.txt: Added.
* http/tests/navigation/redirect-on-reload-updates-history-item.html: Added.
* http/tests/navigation/redirect302-frames-expected.txt:
* http/tests/navigation/redirect302-subframeload-expected.txt:
* http/tests/navigation/resources/redirect-on-back-updates-history-item-goback.html: Added.
* http/tests/navigation/resources/redirect-on-back-updates-history-item.php: Added.
* http/tests/navigation/resources/redirect-on-reload-updates-history-item-goback.html: Added.
* http/tests/navigation/resources/redirect-on-reload-updates-history-item.php: Added.
* http/tests/navigation/resources/redirect-to-cookie.php: Added.
* http/tests/navigation/resources/redirect-updates-history-item-done.html: Added.
* http/tests/navigation/resources/redirect-updates-history-item.js: Added.
(clearLocationCookie):
(setLocationCookie):
(log):
(onpopstate):
* platform/chromium-linux/http/tests/navigation/postredirect-frames-expected.checksum: Removed.
* platform/chromium-linux/http/tests/navigation/postredirect-frames-expected.png: Removed.
* platform/chromium-win/http/tests/navigation/postredirect-frames-expected.checksum: Removed.
* platform/chromium-win/http/tests/navigation/postredirect-frames-expected.png: Removed.
* platform/chromium-win/http/tests/navigation/postredirect-frames-expected.txt: Removed.
* platform/mac/http/tests/navigation/postredirect-frames-expected.checksum: Removed.
* platform/mac/http/tests/navigation/postredirect-frames-expected.png: Removed.
* platform/mac/http/tests/navigation/postredirect-frames-expected.txt: Removed.
* platform/qt/http/tests/navigation/postredirect-frames-expected.txt: Removed.
2011-01-19 Dmitry Titov <dimich@chromium.org>
 
[Chromium] Unreviewed, update of test expectations.
......
main frame - has 1 onunload handler(s)
PASS
============== Back Forward List ==============
curr-> (file test):fast/history/resources/history-replace-updates-current-item-done.html **nav target**
(file test):fast/history/resources/history-replace-updates-current-item-goback.html **nav target**
===============================================
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpBackForwardList();
layoutTestController.waitUntilDone();
}
onunload = function() {
// no page cache
}
onload = function() {
setTimeout(function() {
// This code inserts a new history item using pushState, and then it
// replaces that history item with a navigation to a page that just
// navigates us back to this page. However, before that, we replace
// the URL of the initial page to point at the "done" page such that
// navigating back takes us to that document instead.
//
// This test ensures that we do not treat the initial document and the
// document created by the location.replace command as the same
// document when navigating back. If we treat them the same, then we
// will fail to load the "done" page.
history.replaceState(null, null, 'resources/history-replace-updates-current-item-done.html');
history.pushState(null, null, '?dummystate');
location.replace('history-replace-updates-current-item-goback.html');
}, 0);
}
</script>
<body>history-replace-updates-current-item.html: You should not see this text!</body>
<script>
onload = function() {
if (window.layoutTestController)
layoutTestController.notifyDone();
}
</script>
<body>PASS</body>
<script>
onload = function() {
history.back();
}
</script>
<body>history-replace-updates-current-item-goback.html: You should not see this text!</body>
--------
Frame: 'main'
--------
This is just a minimal page that we navigate in response to an HTTP POST.
If the next line is empty after the colon, it probably means that we made a mistake and requested this page with a GET with no query instead of a POST.
The first text field contained: New form text from user
This page was requested with an HTTP GET
--------
Frame: 'footer'
--------
This is just a minimal page that we navigate to as part of testing back/forward.
============== Back Forward List ==============
http://127.0.0.1:8000/navigation/postredirect-frames.html **nav target**
http://127.0.0.1:8000/navigation/resources/frameset.pl?frameURL=success200.html **nav target**
http://127.0.0.1:8000/navigation/resources/otherpage.html (in frame "footer")
http://127.0.0.1:8000/navigation/resources/success200.html (in frame "main")
curr-> http://127.0.0.1:8000/navigation/resources/frameset.pl?frameURL=success200.html
http://127.0.0.1:8000/navigation/resources/otherpage.html (in frame "footer")
http://127.0.0.1:8000/navigation/resources/postresult.pl?submitwithpostredirect=Submit%20with%20POST%20followed%20by%20a%20redirect&textfield1=New%20form%20text%20from%20user&textfield2=&radiogroup1=female&checkbox2=on&selectgroup1=fiat&textarea1=More%20new%20form%20text%20from%20user%2C%20which%20should%20be%20restored%20when%20we%20return%20to%20this%20page.&redirectHappened=true (in frame "main") **nav target**
===============================================
......@@ -16,6 +16,6 @@ Target of redirect after POST request.
============== Back Forward List ==============
curr-> http://127.0.0.1:8000/navigation/postredirect-frames-goback1.html **nav target**
http://127.0.0.1:8000/navigation/resources/redirect-to-go-back.pl (in frame "target-frame")
http://127.0.0.1:8000/navigation/resources/top-go-back.html (in frame "target-frame")
http://127.0.0.1:8000/navigation/resources/go-back.html **nav target**
===============================================
<script type="text/javascript" src="resources/testcode.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
}
runBasicTest("resources/frameset.pl?frameURL=success200.html", "postredirect");
</script>
This page just kicks off a test, and should not appear in the expected test output.
......
main frame - has 1 onunload handler(s)
PASS
popstate: null
============== Back Forward List ==============
http://127.0.0.1:8000/navigation/redirect-on-back-updates-history-item.html **nav target**
curr-> http://127.0.0.1:8000/navigation/resources/redirect-updates-history-item-done.html **nav target**
http://127.0.0.1:8000/navigation/resources/redirect-on-back-updates-history-item-goback.html **nav target**
===============================================
<script src="resources/redirect-updates-history-item.js"></script>
<script>
// Test that we properly update a history item when returning to the history
// item results in a redirect to a different document. We verify that the
// resulting document is not treated as the same document as the original
// document in history. See redirect-on-back-updates-history-item.php for more
// details.
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpBackForwardList();
layoutTestController.waitUntilDone();
}
onload = function() {
setTimeout(function() {
clearLocationCookie();
location = 'resources/redirect-on-back-updates-history-item.php';
}, 0);
}
</script>
main frame - has 1 onunload handler(s)
main frame - has 1 onunload handler(s)
PASS
popstate: null
============== Back Forward List ==============
http://127.0.0.1:8000/navigation/redirect-on-reload-updates-history-item.html **nav target**
curr-> http://127.0.0.1:8000/navigation/resources/redirect-updates-history-item-done.html **nav target**
http://127.0.0.1:8000/navigation/resources/redirect-on-reload-updates-history-item-goback.html **nav target**
===============================================
<script src="resources/redirect-updates-history-item.js"></script>
<script>
// Test that we properly update a history item when reloading the history item
// results in a redirect to a different document. We verify that the resulting
// document is not treated as the same document as the original document in
// history. See redirect-on-reload-updates-history-item.php for more details.
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpBackForwardList();
layoutTestController.waitUntilDone();
}
onload = function() {
setTimeout(function() {
// These fields are used by subsequent pages in this test. Clear them
// to avoid confusing the test with old state.
clearLocationCookie();
delete sessionStorage.done;
location = 'resources/redirect-on-reload-updates-history-item.php';
}, 0);
}
</script>
......@@ -4,5 +4,5 @@
http://127.0.0.1:8000/navigation/redirect302-frames.html **nav target**
curr-> http://127.0.0.1:8000/navigation/resources/frameset.pl?frameURL=redirect302.pl **nav target**
http://127.0.0.1:8000/navigation/resources/otherpage.html (in frame "footer")
http://127.0.0.1:8000/navigation/resources/redirect302.pl (in frame "main")
http://127.0.0.1:8000/navigation/resources/success200.html (in frame "main")
===============================================
......@@ -7,5 +7,5 @@
http://127.0.0.1:8000/navigation/resources/otherpage.html (in frame "main")
curr-> http://127.0.0.1:8000/navigation/resources/frameset.pl?frameURL=otherpage.html
http://127.0.0.1:8000/navigation/resources/otherpage.html (in frame "footer")
http://127.0.0.1:8000/navigation/resources/redirect302.pl (in frame "main") **nav target**
http://127.0.0.1:8000/navigation/resources/success200.html (in frame "main") **nav target**
===============================================
<script src="redirect-updates-history-item.js"></script>
<script>
onload = function() {
history.back();
}
</script>
<p>redirect-on-back-updates-history-item-goback.html: You should not see this text!</p>
<?php
header('cache-control: no-store');
$location=$_COOKIE['location'];
if ($location!="") {
header('Status: 303 See Other');
header('Location: '.$location);
exit;
}
?>
<script src='redirect-updates-history-item.js'></script>
<script>
onunload = function() {
// no page cache
}
onload = function() {
setTimeout(function() {
// This code inserts a new history item using pushState, and then it
// replaces that history item with a navigation to a page that just
// navigates us back to this page. However, we set the "location"
// cookie so that when we navigate back to this page, we actually
// redirect to the value of the "location" cookie.
setLocationCookie("redirect-updates-history-item-done.html");
history.pushState(null, null, "");
location.replace("redirect-on-back-updates-history-item-goback.html");
}, 0);
}
</script>
<p>redirect-on-back-updates-history-item.php: You should not see this text!</p>
<script src="redirect-updates-history-item.js"></script>
<script>
onload = function() {
clearLocationCookie();
sessionStorage.done = true;
history.back();
}
</script>
<body>redirect-on-reload-updates-history-item-goback.html: You should not see this text!</body>
<?php
header('cache-control: no-store');
$location=$_COOKIE['location'];
if ($location!="") {
header('Status: 303 See Other');
header('Location: '.$location);
exit;
}
?>
<script src='redirect-updates-history-item.js'></script>
<script>
onunload = function() {
// no page cache
}
onload = function() {
setTimeout(function() {
// The first time through here (sessionStorage.done is false), this
// code inserts a new history item using pushState, and then it
// triggers a reload of the history item. However, we set the
// "location" cookie so that when we reload this page, we actually
// redirect to the value of the "location" cookie.
//
// This loads the "goback" page, which bounces us back here after
// setting sessionStorage.done to true. The point of this test is to
// ensure that going back actually performs a real navigation as
// opposed to performing a "same document navigation" as would normally
// be done when navigating back after a pushState.
if (sessionStorage.done) {
location.replace("redirect-updates-history-item-done.html");
} else {
history.pushState(null, null, "");
setLocationCookie("redirect-on-reload-updates-history-item-goback.html");
location.reload();
}
}, 0);
}
</script>
<p>redirect-on-reload-updates-history-item.php: You should not see this text!</p>
<?
header('Status: 303 See Other');
header('Location: '.$_COOKIE['location']);
?>
<script src="redirect-updates-history-item.js"></script>
<script>
onload = function() {
if (window.layoutTestController)
layoutTestController.notifyDone();
}
</script>
<body>PASS</body>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment