mirror of
https://github.com/lexmount/moli.git
synced 2026-11-24 08:02:58 +00:00
Resolve Window.stop() through the receiver's captured Window binding and cancel intercepted fragment/reload navigations as well as descendant frame navigations. Preserve cross-document traversal handling and guard ancestor stops against reentrant abort listeners. Keep Window identity valid across document.open() without targeting replacement LocalWindows. Import the corrected upstream stop-before-commit WPT and cover receiver, shadow-frame, history, promise, and callback reentrancy behavior.
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>
|