Skip to content

Commit

Permalink
View transitions: change harness test to not reload
Browse files Browse the repository at this point in the history
Change-Id: I73ee593bebc58be6b547fc070d60d1d1cdf21d51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6087960
Reviewed-by: Vladimir Levin <[email protected]>
Commit-Queue: Vladimir Levin <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1395432}
  • Loading branch information
noamr authored and chromium-wpt-export-bot committed Dec 12, 2024
1 parent e26600a commit d534e0a
Showing 1 changed file with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,33 @@
document.querySelector("#vt-style").innerHTML = `@view-transition { navigation: auto }`;
}
const params = new URLSearchParams(location.search);
const is_new_page = params.has('new');

if (!is_new_page) {
onload = () => requestAnimationFrame(() => requestAnimationFrame(() => {
optIn();
location.replace(location.href + '?new');
}));
} else {
promise_test(() => {
optIn();
return new Promise((resolve) => {
addEventListener('pagereveal', resolve);
}).then(event => {
assert_not_equals(event.viewTransition, null,
"ViewTransition must be triggered.");
optIn();

// This file includes 3 modes: test, old, new.
// "test" is where testharness runs. "old" -> "new" is where the view transition takes place.
switch (params.get("mode") || "test") {
case "test":
promise_test(async t => {
const event = await new Promise(resolve => {
window.did_reveal = e => { resolve(e) };
const popup = window.open("?mode=old");
t.add_cleanup(() => popup.close());
});

assert_not_equals(event.viewTransition, null, "ViewTransition must be triggered.");
});
break;
case "old":
onload = () => requestAnimationFrame(() => requestAnimationFrame(() => {
location.replace('?mode=new');
}));
break;
case "new":
onpagereveal = e => window.opener.did_reveal(e);
}
</script>

<body>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Alias quis assumenda doloremque, repellat quidem quia blanditiis harum animi corrupti totam sunt provident sapiente at eius sequi labore repellendus velit fugit!
</body>

0 comments on commit d534e0a

Please sign in to comment.