Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / loader / stateobjects / document-destroyed-navigate-back.html
index 02937d2..d812aa2 100644 (file)
@@ -15,45 +15,32 @@ function lastPathComponent()
 }
 
 function runFirstStageOfTest()
-{   
+{
     history.replaceState("FirstEntry", null, "?FirstEntry");
     history.pushState("SecondEntry", null, "?SecondEntry");
     history.back();
 }
 
-function runSecondStageOfTest()
-{
-    alert("Last path component of location is " + lastPathComponent());
-}
-
-function runThirdStageOfTest()
-{
-    alert("Final stage of test loaded");
-}
-
 function runTest()
 {
     if (!sessionStorage.stage) {
         // Location changes need to happen outside the onload handler to generate history entries.
         setTimeout(runFirstStageOfTest, 0);
     } else if (sessionStorage.stage == 2)
-        runSecondStageOfTest();
-    else if (sessionStorage.stage == 3)
-        runThirdStageOfTest();
+        alert("Last path component of location is " + lastPathComponent());
 }
 
-function statePopped()
+function continueTest(state)
 {
-    alert("State popped - " + event.state + " (type " + typeof event.state + ")");
-    if (event.state == "FirstEntry") {
+    if (state == "FirstEntry") {
         history.replaceState("FirstEntryWillLaterBeReactivated", null, "?FirstEntryWillLaterBeReactivated");
         history.forward();
-    } else if (event.state == "SecondEntry") {
+    } else if (state == "SecondEntry") {
         history.replaceState("SecondEntryWillLaterBeReactivated", null, "?SecondEntryWillLaterBeReactivated");
         window.location = "resources/navigate-back.html";
-    } else if (event.state == "SecondEntryWillLaterBeReactivated")
+    } else if (state == "SecondEntryWillLaterBeReactivated")
         history.back();
-    else if (event.state == "FirstEntryWillLaterBeReactivated") {
+    else if (state == "FirstEntryWillLaterBeReactivated") {
         alert("Test complete");
         sessionStorage.clear();
         if (window.testRunner)
@@ -61,14 +48,30 @@ function statePopped()
     }
 }
 
+window.onpopstate = function statePopped()
+{
+    var state = event.state;
+    alert("State popped - " + state + " (type " + typeof state + ")");
+    continueTest(state);
+}
+
+window.onpageshow = function pageShown()
+{
+    if (sessionStorage.stage == 2) {
+        var state = history.state;
+        alert("Page shown - " + state + " (type " + typeof state + ")");
+        continueTest(state);
+    }
+}
+
 </script>
-<body onload="runTest();" onpopstate="statePopped();" onunload="/* disable page cache */">
+<body onload="runTest();" onunload="/* disable page cache */">
 <pre>
 This test:
 -Builds up a list of state object entries with fragment URLs.
 -Navigates through them to verify that the popstate event is fired.
 -Navigates away to a new document, with the old document being destroyed.
--Navigates back to the state object entries and verifies the popstate event is fired even on the new documents.
+-Navigates back to the state object entries and verifies the pageshow or popstate events are fired on the new documents.
 </pre><br>
 <pre id="logger"></pre>
 </body>