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
30 lines
1.1 KiB
HTML
30 lines
1.1 KiB
HTML
<!doctype html>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<iframe id="iframe" name="i" src="/common/blank.html"></iframe>
|
|
<script>
|
|
async_test(t => {
|
|
window.onload = t.step_func(() => {
|
|
navigation.onnavigate = t.step_func_done(() => {
|
|
assert_unreached("onnavigate should not have fired in source window");
|
|
});
|
|
iframe.contentWindow.navigation.onnavigate = t.step_func_done(e => {
|
|
assert_equals(e.navigationType, "push");
|
|
assert_true(e.cancelable);
|
|
assert_true(e.canIntercept);
|
|
assert_false(e.userInitiated);
|
|
assert_true(e.hashChange);
|
|
assert_equals(e.downloadRequest, null);
|
|
assert_equals(new URL(e.destination.url).hash, "#1");
|
|
assert_true(e.destination.sameDocument);
|
|
assert_equals(e.destination.key, null);
|
|
assert_equals(e.destination.id, null);
|
|
assert_equals(e.destination.index, -1);
|
|
assert_equals(e.formData, null);
|
|
e.preventDefault();
|
|
});
|
|
|
|
window.open("/common/blank.html#1", "i");
|
|
});
|
|
}, "window.open() fires navigate event in target window but not source");
|
|
</script>
|