onbeforeunload event return value coercion is not per-spec
[WebKit-https.git] / LayoutTests / fast / events / resources / before-unload-return-string-conversion-frame.html
1 <!DOCTYPE html>
2 <script>
3
4 parent.toStringCalled = false;
5
6 window.runTest = function() {
7     window.onbeforeunload = function(e) {
8         e.returnValue = "PASS";
9         return { toString: function () { parent.toStringCalled = true; return "FAIL"; } };
10     }
11
12     const listener = function(e) {
13         parent.event = e;
14         parent.shouldBeTrue("event.defaultPrevented");
15         parent.shouldBeEqualToString("event.returnValue", "PASS");
16         parent.shouldBeTrue("toStringCalled");
17         parent.setTimeout(function() {
18             parent.finishJSTest();
19         }, 0);
20     }
21
22     window.addEventListener("beforeunload", listener);
23     window.location.href = "about:blank";
24 }
25 </script>