OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <title>Support page for beforeunload-canceling.html</title> |
| 4 |
| 5 <h1>If this goes away, it navigated</h1> |
| 6 |
| 7 <script> |
| 8 "use strict"; |
| 9 |
| 10 window.runTest = (t, { valueToReturn, expectCancelation, setReturnValue, expecte
dReturnValue }) => { |
| 11 window.onbeforeunload = t.step_func(e => { |
| 12 if (setReturnValue !== undefined) { |
| 13 e.returnValue = setReturnValue; |
| 14 } |
| 15 |
| 16 return valueToReturn; |
| 17 }); |
| 18 |
| 19 const listener = t.step_func(e => { |
| 20 top.assert_equals(e.defaultPrevented, expectCancelation, "canceled"); |
| 21 top.assert_equals(e.returnValue, expectedReturnValue, "returnValue"); |
| 22 window.onbeforeunload = null; |
| 23 |
| 24 t.done(); |
| 25 }); |
| 26 |
| 27 window.addEventListener("beforeunload", listener); |
| 28 |
| 29 window.location.href = "about:blank"; |
| 30 }; |
| 31 </script> |
OLD | NEW |