summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/long-animation-frame/tentative/loaf-first-ui-event.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/long-animation-frame/tentative/loaf-first-ui-event.html')
-rw-r--r--testing/web-platform/tests/long-animation-frame/tentative/loaf-first-ui-event.html81
1 files changed, 81 insertions, 0 deletions
diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-first-ui-event.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-first-ui-event.html
new file mode 100644
index 0000000000..7e32010189
--- /dev/null
+++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-first-ui-event.html
@@ -0,0 +1,81 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<title>Long Animation Frame Timing: first UI Event</title>
+<meta name="timeout" content="long">
+<script src=/resources/testdriver.js></script>
+<script src=/resources/testdriver-actions.js></script>
+<script src=/resources/testdriver-vendor.js></script>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/utils.js"></script>
+
+<body>
+<h1>Long Animation Frame: First UI Event</h1>
+<div id="log"></div>
+<script>
+
+promise_test(async t => {
+ const button = document.createElement("button");
+ button.innerText = "Click";
+ document.body.appendChild(button);
+ t.add_cleanup(() => button.remove());
+ const eventPromise = new Promise(resolve => button.addEventListener("click", event => {
+ busy_wait();
+ resolve(event);
+ }));
+ const entryPromise = expect_long_frame_with_script(() => {
+ test_driver.click(button);
+ }, s => s.invoker === "BUTTON.onclick", t);
+ await new Promise(resolve => t.step_timeout(resolve, 0));
+ const event = await eventPromise;
+ const [entry] = await entryPromise;
+ assert_equals(entry.firstUIEventTimestamp, event.timeStamp);
+}, "LoAF should expose firstUIEventTimestamp for click events");
+
+promise_test(async t => {
+ const button = document.createElement("button");
+ button.innerText = "Hover";
+ document.body.appendChild(button);
+ t.add_cleanup(() => button.remove());
+ let expectedTimestamp = null;
+ const entryPromise = expect_long_frame_with_script(async () => {
+ const eventPromise = new Promise(resolve => button.addEventListener("pointermove", event => {
+ busy_wait();
+ expectedTimestamp = event.timeStamp;
+ resolve();
+ }));
+
+ const actions = new test_driver.Actions()
+ .pointerMove(0, 0, {origin: button})
+ .pointerDown()
+ .pointerUp();
+ await actions.send();
+ await eventPromise;
+ }, (script, entry) =>
+ script.invoker === "BUTTON.onpointermove" &&
+ entry.firstUIEventTimestamp === expectedTimestamp, t);
+}, "LoAF should expose firstUIEventTimestamp for pointermove events");
+
+promise_test(async t => {
+ const button = document.createElement("button");
+ button.innerText = "Click";
+ document.body.appendChild(button);
+ t.add_cleanup(() => button.remove());
+ let firstUIEventTimestamp = null;
+ const eventPromise = new Promise(resolve => button.addEventListener("click", event => {
+ if (firstUIEventTimestamp)
+ resolve(event);
+ else {
+ firstUIEventTimestamp = event.timeStamp;
+ busy_wait();
+ }
+ }));
+ const entryPromise = expect_long_frame_with_script(() => {
+ test_driver.click(button);
+ test_driver.click(button);
+ }, s => s.invoker === "BUTTON.onclick", t);
+ const [event, [entry]] = await Promise.all([eventPromise, entryPromise]);
+ assert_equals(entry.firstUIEventTimestamp, firstUIEventTimestamp);
+}, "firstUIEventTimestamp doesn't have to come from a long script");
+</script>
+</body>