| OLD | NEW | 
|   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         history.forward(); |  27         history.forward(); | 
|  38     else if (window.testRunner) |  28     else if (window.testRunner) | 
|  39         testRunner.notifyDone(); |  29         testRunner.notifyDone(); | 
|  40 } |  30 } | 
|  41  |  31  | 
|  42 window.onpopstate = statePopped; |  32 window.onpopstate = statePopped; | 
|  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 -Uses window.onpopstate to add a popstate handler |  38 -Uses window.onpopstate to add a popstate handler | 
|  49 -Makes a call to pushState() |  39 -Makes a call to pushState() | 
|  50 -Makes sure the history length is correct |  40 -Makes sure the history length is correct | 
|  51 -Goes back, and makes sure the popstate event is correct |  41 -Goes back, and makes sure the popstate event is correct | 
|  52 -Goes forward, and makes sure the popstate event is correct |  42 -Goes forward, and makes sure the popstate event is correct | 
|  53 </pre><br> |  43 </pre><br> | 
|  54 <pre id="logger"></pre> |  44 <pre id="logger"></pre> | 
|  55 </body> |  45 </body> | 
|  56 </html> |  46 </html> | 
| OLD | NEW |