diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-view-transitions/input-targets-root-while-render-blocked.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-view-transitions/input-targets-root-while-render-blocked.html')
-rw-r--r-- | testing/web-platform/tests/css/css-view-transitions/input-targets-root-while-render-blocked.html | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-view-transitions/input-targets-root-while-render-blocked.html b/testing/web-platform/tests/css/css-view-transitions/input-targets-root-while-render-blocked.html new file mode 100644 index 0000000000..dbeb39da54 --- /dev/null +++ b/testing/web-platform/tests/css/css-view-transitions/input-targets-root-while-render-blocked.html @@ -0,0 +1,105 @@ +<!DOCTYPE html> +<html> +<title>View transitions: ensure input targets document root while rendering is suppressed</title> +<link rel="help" href="https://github.com/WICG/view-transitions"> +<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7797"> +<link rel="author" href="mailto:bokan@chromium.org"> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-actions.js"></script> +<script src="/resources/testdriver-vendor.js"></script> + +<style> +:root { + /* Ensure clicks during the transition fall through the pseudo tree root to + * real DOM */ + view-transition-name: none; +} + +::view-transition { + /* Ensure clicks during the transition fall through the pseudo tree root to + * real DOM */ + pointer-events: none; + width: 0; + height: 0; +} + +::view-transition-group(*) { + animation-duration: 30s; +} + +#clicktarget { + width: 100px; + height: 100px; + background: red; +} + +#transition { + width: 100px; + height: 100px; + background: blue; + contain: paint; + view-transition-name: transitionElement; +} +</style> + +<div id="clicktarget"></div> +<div id="transition"></div> + +<script> +const target = document.getElementById("clicktarget"); + +async function sendAndWaitForClick() { + return new Promise(async (resolve) => { + + function eventHandler(ev) { + resolve(ev); + } + + document.documentElement.addEventListener("click", eventHandler); + + await new test_driver.Actions() + .setContext(window) + .addPointer("mousePointer1", "mouse") + .pointerMove(10, 10, {origin: 'viewport', sourceName: "mousePointer1"}) + .pointerDown({sourceName: "mousePointer1"}) + .pointerUp({sourceName: "mousePointer1"}) + .send(); + + document.documentElement.removeEventListener("click", eventHandler); + }); +} + +promise_test(async t => { + assert_implements(document.startViewTransition, "Missing document.startViewTransition"); + assert_not_equals(target, null, "PRECONDITION: target element is valid"); + + // Ensure input is initialized before blocking rendering. + await new test_driver.Actions() + .setContext(window) + .addPointer("mousePointer1", "mouse") + .pointerMove(0, 0, {origin: "viewport", sourceName: "mousePointer1"}) + .send(); + + let clickEvent = null; + + let transition = document.startViewTransition(async () => { + clickEvent = await sendAndWaitForClick(); + }); + + await transition.ready; + + assert_equals(clickEvent.target, document.documentElement, + "Events must target the transition root while render blocked"); + clickEvent = null; + + clickEvent = await sendAndWaitForClick(); + + // This just ensures we're not passing the above check by accident. + assert_equals(clickEvent.target, target, + "During transition, event should hit real DOM"); + +}, "Input when rendering suppressed targets root"); +</script> |