Automatic update from web-platform-tests `window.stop()` should be able to cancel intercepted hash navigations (#60386) See https://github.com/whatwg/html/pull/12519 -- wpt-commits: 86f7d9f9f3656576f8c32aed865efda91e531eae wpt-pr: 60386
57 lines
1.8 KiB
HTML
57 lines
1.8 KiB
HTML
<!doctype html>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="../navigation-methods/return-value/resources/helpers.js"></script>
|
|
<body>
|
|
<script>
|
|
promise_test(async t => {
|
|
// Wait for after the load event because window.stop() hangs the test harness
|
|
// if called before the load event.
|
|
await new Promise(resolve => window.onload = () => t.step_timeout(resolve, 0));
|
|
}, "Setup");
|
|
|
|
promise_test(async t => {
|
|
navigation.onnavigate = e => {
|
|
e.intercept({ precommitHandler: async () => {} });
|
|
};
|
|
|
|
navigation.onnavigatesuccess = t.unreached_func("navigatesuccess must not fire");
|
|
let navigateerror_called = false;
|
|
navigation.onnavigateerror = t.step_func(() => {
|
|
navigateerror_called = true;
|
|
assert_equals(location.hash, "");
|
|
});
|
|
|
|
let promises = navigation.navigate("?ShouldNotCommit");
|
|
assert_equals(location.hash, "");
|
|
|
|
window.stop();
|
|
await assertBothRejectDOM(t, promises, "AbortError");
|
|
|
|
assert_equals(location.hash, "");
|
|
assert_true(navigateerror_called);
|
|
}, " precommitHandler with window.stop() before navigation commit");
|
|
|
|
promise_test(async t => {
|
|
navigation.onnavigate = e => {
|
|
e.intercept({ precommitHandler: async () => {} });
|
|
};
|
|
|
|
navigation.onnavigateerror = t.unreached_func("onnavigateerror must not fire");
|
|
navigation.onnavigatesuccess = t.unreached_func("onnavigatesuccess must not fire");
|
|
navigation.onnavigateerror = t.step_func(() => {
|
|
navigateerror_called = true;
|
|
});
|
|
|
|
let promises = navigation.navigate("#ShouldCommit");
|
|
assert_equals(location.hash, "");
|
|
|
|
window.stop();
|
|
await assertBothRejectDOM(t, promises, "AbortError");
|
|
|
|
assert_equals(location.hash, "");
|
|
assert_true(navigateerror_called);
|
|
}, " precommitHandler with window.stop() before fragment navigation commit");
|
|
</script>
|
|
</body>
|