Bug 1757847 [wpt PR 33036] - Update wpt metadata, a=testonly
[gecko.git] / testing / web-platform / tests / app-history / navigate / return-value / goTo-beforeunload.html
blob3b2722235eecc6be300694bdd97b91a3eafb29ac
1 <!doctype html>
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>
8 <script>
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");
17 let assertionPromise;
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);
23 });
24 i.contentWindow.navigation.navigate("?1");
26 assert_not_equals(assertionPromise, undefined);
27 await assertionPromise;
29 assert_equals(navigateEventCount, 1);
30 }, "traverseTo() inside onbeforeunload");
31 </script>