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

Side by Side Diff: LayoutTests/fast/loader/stateobjects/pushstate-then-replacestate.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 testRunner.clearBackForwardList(); 6 testRunner.clearBackForwardList();
7 testRunner.dumpAsText(); 7 testRunner.dumpAsText();
8 testRunner.waitUntilDone(); 8 testRunner.waitUntilDone();
9 } 9 }
10 10
11 function log(txt) 11 function log(txt)
12 { 12 {
13 document.getElementById("logger").innerText += txt + "\n"; 13 document.getElementById("logger").innerText += txt + "\n";
14 } 14 }
15 15
16 function runTest() 16 function runTest()
17 { 17 {
18 history.pushState("StateStringData", "New title"); 18 history.pushState("StateStringData", "New title");
19 log("History length is " + history.length); 19 log("History length is " + history.length);
20 history.replaceState(1, "Replaced title"); 20 history.replaceState(1, "Replaced title");
21 log("History length is " + history.length); 21 log("History length is " + history.length);
22 history.back(); 22 history.back();
23 } 23 }
24 24
25 var beganTest = false;
26
27 onpopstate = function(event) 25 onpopstate = function(event)
28 { 26 {
29 // The first time popstate fires, it's because the page has finished loading .
30 // Only then can we begin the test.
31 if (!beganTest) {
32 beganTest = true;
33 runTest();
34 return;
35 }
36
37 log("State popped - " + event.state + " (type " + typeof event.state + ")"); 27 log("State popped - " + event.state + " (type " + typeof event.state + ")");
38 if (event.state == null) 28 if (event.state == null)
39 history.forward(); 29 history.forward();
40 else if (window.testRunner) 30 else if (window.testRunner)
41 testRunner.notifyDone(); 31 testRunner.notifyDone();
42 } 32 }
43 33
44 </script> 34 </script>
45 <body> 35 <body onload="runTest();">
46 <pre> 36 <pre>
47 This test does the following: 37 This test does the following:
48 -Makes a call to pushState() 38 -Makes a call to pushState()
49 -Makes sure the history length is correct 39 -Makes sure the history length is correct
50 -Makes a call to replaceState() 40 -Makes a call to replaceState()
51 -Makes sure the history length is correct 41 -Makes sure the history length is correct
52 -Goes back, and makes sure the popstate event is correct 42 -Goes back, and makes sure the popstate event is correct
53 -Goes forward, and makes sure the popstate event represents the replaced state o bject 43 -Goes forward, and makes sure the popstate event represents the replaced state o bject
54 </pre><br> 44 </pre><br>
55 <pre id="logger"></pre> 45 <pre id="logger"></pre>
56 </body> 46 </body>
57 </html> 47 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698