Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
// 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 () => {} });
};
Expand All @@ -20,14 +22,36 @@
assert_equals(location.hash, "");
});

let promises = navigation.navigate("#ShouldNotCommit");
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 commit");
}, " 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");
let navigatesuccess_called = false;
navigation.onnavigatesuccess = t.step_func(() => {
navigatesuccess_called = true;
assert_equals(location.hash, "#ShouldCommit");
});

let promises = navigation.navigate("#ShouldCommit");
assert_equals(location.hash, "");

window.stop();
await assertBothFulfillEntryNotAvailable(t, promises);

assert_equals(location.hash, "#ShouldCommit");
assert_true(navigatesuccess_called);
}, " precommitHandler with window.stop() before fragment navigation commit");
</script>
</body>
Loading