Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: LayoutTests/fast/loader/stateobjects/document-destroyed-navigate-back-with-fragment-scroll.html

Issue 136463002: Don't fire popstate event on initial document load (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix replacestate-in-iframe test Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script> 3 <script>
4 4
5 if (window.testRunner) { 5 if (window.testRunner) {
6 if (!sessionStorage.stage) 6 if (!sessionStorage.stage)
7 testRunner.clearBackForwardList(); 7 testRunner.clearBackForwardList();
8 testRunner.dumpAsText(); 8 testRunner.dumpAsText();
9 testRunner.waitUntilDone(); 9 testRunner.waitUntilDone();
10 } 10 }
(...skipping 30 matching lines...) Expand all
41 { 41 {
42 alert("LOADED"); 42 alert("LOADED");
43 if (!sessionStorage.stage) 43 if (!sessionStorage.stage)
44 runFirstStageOfTest(); 44 runFirstStageOfTest();
45 else if (sessionStorage.stage == 2) 45 else if (sessionStorage.stage == 2)
46 runSecondStageOfTest(); 46 runSecondStageOfTest();
47 else if (sessionStorage.stage == 3) 47 else if (sessionStorage.stage == 3)
48 runThirdStageOfTest(); 48 runThirdStageOfTest();
49 } 49 }
50 50
51 var beganTest = false;
52
53 onpopstate = function() 51 onpopstate = function()
54 { 52 {
55 // The first time popstate fires, it's because the page has finished loading .
56 // Only then can we begin the test.
57 if (!beganTest) {
58 beganTest = true;
59 runTest();
60 // Continue with the handler if we've already began the test.
61 if (!sessionStorage.stage)
62 return;
63 }
64
65 alert("State popped - " + event.state + " (type " + typeof event.state + ")" ); 53 alert("State popped - " + event.state + " (type " + typeof event.state + ")" );
66 54
67 // FIXME: Once the popstate and hashchange events fire asynchronously, we 55 // FIXME: Once the popstate and hashchange events fire asynchronously, we
68 // can eliminate this setTimeout hack. The hashchange event currently runs 56 // can eliminate this setTimeout hack. The hashchange event currently runs
69 // synchronously following the popstate event, but the calls to 57 // synchronously following the popstate event, but the calls to
70 // replaceState cause the location to change immediately. That confuses 58 // replaceState cause the location to change immediately. That confuses
71 // our hashchange handler, which expects to see the "old" value of the 59 // our hashchange handler, which expects to see the "old" value of the
72 // location. 60 // location.
73 61
74 var state = event.state; 62 var state = event.state;
(...skipping 14 matching lines...) Expand all
89 alert("hashChanged - Last path component of location is " + lastPathComponent (event.newURL)); 77 alert("hashChanged - Last path component of location is " + lastPathComponent (event.newURL));
90 if (hashOf(event.newURL) == "#FirstEntryWillLaterBeReactivated") { 78 if (hashOf(event.newURL) == "#FirstEntryWillLaterBeReactivated") {
91 alert("Test complete"); 79 alert("Test complete");
92 sessionStorage.clear(); 80 sessionStorage.clear();
93 if (window.testRunner) 81 if (window.testRunner)
94 testRunner.notifyDone(); 82 testRunner.notifyDone();
95 } 83 }
96 } 84 }
97 85
98 </script> 86 </script>
99 <body onunload="/* disable page cache */"> 87 <body onload="runTest();" onunload="/* disable page cache */">
100 <pre> 88 <pre>
101 This test: 89 This test:
102 -Builds up a list of state object entries with fragment URLs. 90 -Builds up a list of state object entries with fragment URLs.
103 -Navigates through them to verify that the popstate and hashchanged events are f ired. 91 -Navigates through them to verify that the popstate and hashchanged events are f ired.
104 -Navigates away to a new document, with the old document being destroyed. 92 -Navigates away to a new document, with the old document being destroyed.
105 -Navigates back to the state object entries and verifies the popstate event is f ired even on the new documents. 93 -Navigates back to the state object entries and verifies the popstate event is f ired even on the new documents.
106 </pre> 94 </pre>
107 </body> 95 </body>
108 </html> 96 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698