Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /navigation-api/navigate-event/intercept-stops-ongoing-cross-document-navigation.html - WPT Dashboard Interop Dashboard
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="i" src="/common/blank.html"></iframe>
<script>
promise_test(async t => {
await new Promise(resolve => window.onload = resolve);
i.contentWindow.marker = "alive";
// The response is delayed, so this navigation is still in flight when the next one starts.
const first = i.contentWindow.navigation.navigate("/common/blank.html?pipe=trickle(d1)");
first.committed.catch(() => {});
const firstFinished = first.finished.then(() => "fulfilled", e => e.name);
await new Promise(resolve => t.step_timeout(resolve, 200));
i.contentWindow.navigation.onnavigate = e => e.intercept();
await i.contentWindow.navigation.navigate("?intercepted").finished;
assert_equals(await firstFinished, "AbortError", "the first navigation is aborted");
// Leave time for the delayed response to arrive and commit if the first navigation was not stopped.
await new Promise(resolve => t.step_timeout(resolve, 1500));
assert_equals(i.contentWindow.marker, "alive", "the document was not replaced");
assert_equals(i.contentWindow.location.search, "?intercepted");
}, "navigate() whose navigate event is intercepted stops the cross-document navigation it replaces");
</script>