Skip to content

Commit

Permalink
Bug 1885867 [wpt PR 45162] - Reland https://chromium-review.googlesou…
Browse files Browse the repository at this point in the history
…rce.com/c/chromium/src/+/5374309, a=testonly

Automatic update from web-platform-tests
Reland https://chromium-review.googlesource.com/c/chromium/src/+/5374309

... This time marking test as long.

View-transitions should only be allowed when page is visible

- Skip the transition if document becomes hidden
- Disallow oubound cross-document view transitions when document is
  hidden
- Skip inbound cross-document view transition if document becomes
  hidden
- When calling startViewTransition() in a hidden document, start is
  as skipped.

Based on following CSS resolution:
w3c/csswg-drafts#9543 (comment)

Bug: 329302331
Change-Id: Ifbd8be3765307d2756ef2955eb6ef72e4b2b8756
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5372454
Reviewed-by: David Bokan <bokan@chromium.org>
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1274101}

--

wpt-commits: d4535158a3196da9278c836c1d679545b026aaaf
wpt-pr: 45162
  • Loading branch information
noamr authored and moz-wptsync-bot committed Mar 21, 2024
1 parent 5e04dfa commit 45b47d6
Showing 1 changed file with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<title>View transitions: Transition in a hidden page</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/page-visibility/resources/window_state_context.js"></script>
<style>
::view-transition-group(*) {
animation-duration: 5s;
}
</style>
<script>
promise_test(async t => {
assert_implements(document.startViewTransition, "Missing document.startViewTransition");

const wsc = window_state_context(t);
await wsc.minimize();
assert_true(document.hidden);
const transition = document.startViewTransition();
await wsc.restore();
const [readyResult] = await Promise.allSettled([transition.ready]);
assert_equals(readyResult.status, "rejected");
}, "A view transition should be immediately skipped if started when document is hidden");

promise_test(async t => {
assert_implements(document.startViewTransition, "Missing document.startViewTransition");

const wsc = window_state_context(t);
const transition = document.startViewTransition(async () => {
await wsc.minimize();
});

let event_fired = false;

window.addEventListener("visibilitychange", () => {
if (document.hidden)
event_fired = true;
});

// Restoring so that the document has an opportunity to present the real
// frame and start the transition's animation.
await wsc.restore();

const [readyResult] = await Promise.allSettled([transition.ready]);
assert_true(event_fired, "visibilitychange event should fire before skipping the transition");
await transition.finished;
assert_equals(readyResult.status, "rejected");
}, "A view transition should be skipped when a document becomes hidden while processing update callback");

promise_test(async t => {
assert_implements(document.startViewTransition, "Missing document.startViewTransition");
assert_false(document.hidden);
const wsc = window_state_context(t);
const transition = document.startViewTransition(() => { });
await transition.ready;
await new Promise(resolve => requestAnimationFrame(resolve));
await wsc.minimize();
const result = await new Promise(resolve => {
transition.finished.then(() => resolve("finished"));
t.step_timeout(() => resolve("timeout"), 1000);
});

assert_equals(result, "finished");
}, "A view transition should be skipped when a document becomes hidden while animating");
</script>
</body>

</html>

0 comments on commit 45b47d6

Please sign in to comment.