Skip to content

Commit 9dd2c68

Browse files
noamrchromium-wpt-export-bot
authored andcommitted
Expose navigation.transition.to
This exposes the destination of an ongoing navigation. Spec PR: whatwg/html#11692 I2P: https://groups.google.com/a/chromium.org/d/msgid/blink-dev/68d4ff4d.2b0a0220.29ae18.0091.GAE%40google.com [email protected] Bug: 447171238 Change-Id: I1d2fbb7c0b7f2656ca4392be4d1beac34d9012ac
1 parent 3032c66 commit 9dd2c68

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!doctype html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<script>
5+
promise_test(async (t) => {
6+
// Wait for after the load event so that the navigation doesn't get converted
7+
// into a replace navigation.
8+
await new Promise(r => window.onload = () => t.step_timeout(r, 0));
9+
const precommit = Promise.withResolvers();
10+
const handler = Promise.withResolvers();
11+
const handler_done = Promise.withResolvers();
12+
const commit = Promise.withResolvers();
13+
navigation.addEventListener("navigate", e => {
14+
e.intercept({
15+
async precommitHandler() {
16+
precommit.resolve(e);
17+
await commit.promise;
18+
},
19+
async handler() {
20+
handler.resolve();
21+
await handler_done.promise;
22+
}
23+
});
24+
});
25+
26+
assert_equals(navigation.transition, null);
27+
navigation.navigate("?next");
28+
const navigate_event = await precommit.promise;
29+
const old_entry = navigation.currentEntry;
30+
assert_equals(navigation.transition.from, old_entry);
31+
assert_equals(navigation.transition.to, navigate_event.destination);
32+
commit.resolve();
33+
await handler.promise;
34+
assert_equals(navigation.transition.from, old_entry);
35+
assert_equals(navigation.transition.to, navigate_event.destination);
36+
assert_equals(navigation.transition.to.url, navigation.currentEntry.url);
37+
handler_done.resolve();
38+
}, "navigation.transition.to matches the navigate event's destination");
39+
</script>

0 commit comments

Comments
 (0)