forked from mirrors/gecko-dev
Automatic update from web-platform-tests Implement navigateEvent.intercept() and navigateEvent.canIntercept Follows https://github.com/WICG/navigation-api/pull/235 intercept() works very similarly to transitionWhile(), except that instead of taking a mandatory Promise, it takes an optional handler function. If a function is provided and it returns a promise, navigation finish will be delayed until the Promise resolve, just as transitionWhile() delays navigation finish for its Promise. canIntercept is identical to canTransition. Intent to ship: https://groups.google.com/a/chromium.org/g/blink-dev/c/jyWqjAEv5LU Bug: 1336000 Change-Id: I94edd7fdc727080594f16fe4511cb7c302d88941 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3688177 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Commit-Queue: Nate Chapin <japhet@chromium.org> Reviewed-by: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/main@{#1026325} -- wpt-commits: 5f0779f40dbb30349778db64db04754df8c4a4ef wpt-pr: 34353
23 lines
1 KiB
HTML
23 lines
1 KiB
HTML
<!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);
|
|
|
|
let oncurrententrychange_called = false;
|
|
let original_entry = i.contentWindow.navigation.currentEntry;
|
|
i.contentWindow.navigation.oncurrententrychange = t.step_func(e => {
|
|
oncurrententrychange_called = true;
|
|
assert_equals(e.from, original_entry);
|
|
assert_equals(e.from.index, -1);
|
|
assert_equals(e.navigationType, "replace");
|
|
assert_equals(i.contentWindow.navigation.currentEntry.index, 0);
|
|
});
|
|
i.contentWindow.navigation.onnavigate = e => e.intercept();
|
|
let result = i.contentWindow.navigation.navigate("/common/blank.html?1", { history: "replace" });
|
|
assert_true(oncurrententrychange_called);
|
|
await result.committed;
|
|
}, "currententrychange fires for navigation.navigate() with replace intercepted by intercept()");
|
|
</script>
|