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

Side by Side Diff: LayoutTests/fast/loader/stateobjects/popstate-after-load-complete-body-attribute.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.back(); 20 history.back();
21 } 21 }
22 22
23 var beganTest = false;
24
25 function statePopped() 23 function statePopped()
26 { 24 {
27 // The first time popstate fires, it's because the page has finished loading .
28 // Only then can we begin the test.
29 if (!beganTest) {
30 beganTest = true;
31 runTest();
32 return;
33 }
34
35 log("State popped - " + event.state + " (type " + typeof event.state + ")"); 25 log("State popped - " + event.state + " (type " + typeof event.state + ")");
36 if (event.state == null) { 26 if (event.state == null) {
37 document.body.onpopstate = statePopped; 27 document.body.onpopstate = statePopped;
38 history.forward(); 28 history.forward();
39 } else if (window.testRunner) 29 } else if (window.testRunner)
40 testRunner.notifyDone(); 30 testRunner.notifyDone();
41 } 31 }
42 32
43 </script> 33 </script>
44 <body> 34 <body onload="runTest();">
45 <pre> 35 <pre>
46 This test does the following: 36 This test does the following:
47 -Uses body.onpopstate to add a popstate handler (both by using the inline attrib ute and a script-assigned attribute) 37 -Uses body.onpopstate to add a popstate handler (both by using the inline attrib ute and a script-assigned attribute)
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 -Goes back, and makes sure the popstate event is correct 40 -Goes back, and makes sure the popstate event is correct
51 -Goes forward, and makes sure the popstate event is correct 41 -Goes forward, and makes sure the popstate event is correct
52 </pre><br> 42 </pre><br>
53 <pre id="logger"></pre> 43 <pre id="logger"></pre>
54 </body> 44 </body>
55 <script> 45 <script>
56 document.body.onpopstate = statePopped; 46 document.body.onpopstate = statePopped;
57 </script> 47 </script>
58 </html> 48 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698