| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <p>Check that setting a custom getter for history.state works correctly and that
PopStateEvent.state still has a correct value.</p> | |
| 3 <pre id=log></pre> | |
| 4 <script> | |
| 5 function log(msg) { | |
| 6 document.querySelector("#log").innerHTML += msg + "<br>"; | |
| 7 } | |
| 8 | |
| 9 if (window.testRunner) { | |
| 10 testRunner.clearBackForwardList(); | |
| 11 testRunner.dumpAsText(); | |
| 12 testRunner.waitUntilDone(); | |
| 13 } | |
| 14 | |
| 15 function test() { | |
| 16 if (!("state" in history)) { | |
| 17 log("FAIL: history.state is not defined"); | |
| 18 return; | |
| 19 } | |
| 20 | |
| 21 try { | |
| 22 Object.defineProperty(history, "state", { get: function () { return "oh
hai" } }); | |
| 23 } catch (e) { | |
| 24 // history.state is not configurable in JSC. | |
| 25 log(e.name == "TypeError" ? "PASS" : ("FAIL: unexpected exception: " + e
)); | |
| 26 testRunner.notifyDone(); | |
| 27 return; | |
| 28 } | |
| 29 | |
| 30 if (history.state !== "oh hai") { | |
| 31 log('FAIL: history.state != "oh hai"'); | |
| 32 } | |
| 33 | |
| 34 history.pushState(42, "", ""); | |
| 35 history.pushState(43, "", ""); | |
| 36 | |
| 37 window.onpopstate = function(e) { | |
| 38 if (e.state !== 42) | |
| 39 log("FAIL: e.state expected 42, was " + e.state + " (of type " + typ
eof e.state + ")"); | |
| 40 else | |
| 41 log("PASS"); | |
| 42 if (window.testRunner) | |
| 43 testRunner.notifyDone(); | |
| 44 } | |
| 45 | |
| 46 history.back(); | |
| 47 } | |
| 48 | |
| 49 test(); | |
| 50 </script> | |
| OLD | NEW |