2011-04-04 Yong Li <yoli@rim.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 17:05:55 +0000 (17:05 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 17:05:55 +0000 (17:05 +0000)
        Reviewed by Antonio Gomes.

        https://bugs.webkit.org/show_bug.cgi?id=55969
        Add a test that verifies history scroll position is restored
        when WebKit goes forward from an unreachable URL error page.
        (Error page handling is only supported by Qt DRT.)

        * platform/qt/fast/history/back-to-unreachable-url-then-forward-expected.txt: Added.
        * platform/qt/fast/history/back-to-unreachable-url-then-forward.html: Added.
        * platform/qt/fast/history/resources/check-scroll-position.html: Added.
2011-04-04  Yong Li  <yoli@rim.com>

        Reviewed by Antonio Gomes.

        https://bugs.webkit.org/show_bug.cgi?id=55969
        Fix the issue that document state is not saved when
        going backward and ending up with error page.

        Test: platform/qt/fast/history/back-to-unreachable-url-then-forward.html

        (For manual test, load a non-existent html first, then load
        fast/history/resources/check-scroll-position.html, then go
        back and go forward. If it doesn't show "SUCCESS" at the bottom
        of the page, your browser has failed the test)

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::load):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82843 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/qt/fast/history/back-to-unreachable-url-then-forward-expected.txt [new file with mode: 0644]
LayoutTests/platform/qt/fast/history/back-to-unreachable-url-then-forward.html [new file with mode: 0644]
LayoutTests/platform/qt/fast/history/resources/check-scroll-position.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/FrameLoader.cpp

index d35909e..6a0ed58 100644 (file)
@@ -1,3 +1,16 @@
+2011-04-04  Yong Li  <yoli@rim.com>
+
+        Reviewed by Antonio Gomes.
+
+        https://bugs.webkit.org/show_bug.cgi?id=55969
+        Add a test that verifies history scroll position is restored
+        when WebKit goes forward from an unreachable URL error page.
+        (Error page handling is only supported by Qt DRT.)
+
+        * platform/qt/fast/history/back-to-unreachable-url-then-forward-expected.txt: Added.
+        * platform/qt/fast/history/back-to-unreachable-url-then-forward.html: Added.
+        * platform/qt/fast/history/resources/check-scroll-position.html: Added.
+
 2011-04-04  Jessie Berlin  <jberlin@apple.com>
 
         Remove a test from the win-wk2 skipped list that does not exist.
diff --git a/LayoutTests/platform/qt/fast/history/back-to-unreachable-url-then-forward-expected.txt b/LayoutTests/platform/qt/fast/history/back-to-unreachable-url-then-forward-expected.txt
new file mode 100644 (file)
index 0000000..ff43ca4
--- /dev/null
@@ -0,0 +1 @@
+SUCCESS
diff --git a/LayoutTests/platform/qt/fast/history/back-to-unreachable-url-then-forward.html b/LayoutTests/platform/qt/fast/history/back-to-unreachable-url-then-forward.html
new file mode 100644 (file)
index 0000000..02e0f07
--- /dev/null
@@ -0,0 +1,35 @@
+<script>
+// Pre-conditions
+// - Error page handling is supported on DRT.
+
+// Navigation steps:
+// 1- loads unreachable URL.
+// 2- loads check-scroll-position.html.
+// 3- executes back and forward navigations.
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+    layoutTestController.handleErrorPages();
+}
+
+function onPageShow(evt)
+{
+    if (window.layoutTestController) {
+        if (!evt.persisted) {
+            // This is the first time the page has been loaded, then setup the
+            // to-be-tested scenario.
+            layoutTestController.queueLoad("./non-existent.html");
+            layoutTestController.queueLoad("resources/check-scroll-position.html");
+            layoutTestController.queueBackNavigation(1);
+            layoutTestController.queueForwardNavigation(1);
+        } else {
+            // The page is loaded again? So either the DRT doesn't support error page
+            // or it doesn't save a history item for the error page.
+        }
+    }
+}
+
+window.onpageshow = onPageShow;
+</script>
+<body></body>
diff --git a/LayoutTests/platform/qt/fast/history/resources/check-scroll-position.html b/LayoutTests/platform/qt/fast/history/resources/check-scroll-position.html
new file mode 100644 (file)
index 0000000..0d31dfe
--- /dev/null
@@ -0,0 +1,21 @@
+<head>
+<title>Check Scroll Position</title>
+<script>
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+function checkScrollPosition()
+{
+    if (window.pageYOffset != 0)
+        document.getElementById("result").innerHTML = "SUCCESS";
+    else
+        window.scroll(0, 500);
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+onload = checkScrollPosition;
+
+</script>
+</head>
+<body><p style="margin-top:1000px" id="result"></p></body>
index 1795e6c..7b39188 100644 (file)
@@ -1,3 +1,21 @@
+2011-04-04  Yong Li  <yoli@rim.com>
+
+        Reviewed by Antonio Gomes.
+
+        https://bugs.webkit.org/show_bug.cgi?id=55969
+        Fix the issue that document state is not saved when
+        going backward and ending up with error page.
+
+        Test: platform/qt/fast/history/back-to-unreachable-url-then-forward.html
+
+        (For manual test, load a non-existent html first, then load
+        fast/history/resources/check-scroll-position.html, then go
+        back and go forward. If it doesn't show "SUCCESS" at the bottom
+        of the page, your browser has failed the test)
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::load):
+
 2011-04-04  Sergio Villar Senin  <svillar@igalia.com>
 
         Reviewed by Martin Robinson.
index f1020e1..e30162d 100644 (file)
@@ -1466,6 +1466,11 @@ void FrameLoader::load(DocumentLoader* newDocumentLoader)
     // shouldn't a more explicit type of reload be defined, that means roughly 
     // "load without affecting history" ? 
     if (shouldReloadToHandleUnreachableURL(newDocumentLoader)) {
+        // shouldReloadToHandleUnreachableURL() returns true only when the original load type is back-forward.
+        // In this case we should save the document state now. Otherwise the state can be lost because load type is
+        // changed and updateForBackForwardNavigation() will not be called when loading is committed.
+        history()->saveDocumentAndScrollState();
+
         ASSERT(type == FrameLoadTypeStandard);
         type = FrameLoadTypeReload;
     }