2 <script src=
"/resources/testharness.js"></script>
3 <script src=
"/resources/testharnessreport.js"></script>
4 <script src=
"resources/helpers.js"></script>
6 <iframe id=
"i" src=
"/common/blank.html"></iframe>
9 promise_test(async t
=> {
10 await
new Promise(resolve
=> window
.onload
= resolve
);
12 let navigateEventCount
= 0;
13 i
.contentWindow
.navigation
.onnavigate
= () => navigateEventCount
++;
14 i
.contentWindow
.navigation
.onnavigatesuccess
= t
.unreached_func("onnavigatesuccess should not be called");
15 i
.contentWindow
.navigation
.onnavigateerror
= t
.unreached_func("onnavigateerror should not be called");
18 // The iframe does not have sticky activation, so per
19 // https://html.spec.whatwg.org/#prompt-to-unload-a-document, no prompt is
20 // shown and the navigation will proceed.
21 i
.contentWindow
.onbeforeunload
= t
.step_func(() => {
22 assertionPromise
= assertBothRejectDOM(t
, i
.contentWindow
.navigation
.traverseTo(i
.contentWindow
.navigation
.currentEntry
.key
), "InvalidStateError", i
.contentWindow
);
24 i
.contentWindow
.navigation
.navigate("?1");
26 assert_not_equals(assertionPromise
, undefined);
27 await assertionPromise
;
29 assert_equals(navigateEventCount
, 1);
30 }, "traverseTo() inside onbeforeunload");