From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../tests/long-animation-frame/META.yml | 2 + .../long-animation-frame/tentative/loaf-basic.html | 57 +++++++++ .../tentative/loaf-blocking-duration.html | 65 ++++++++++ .../tentative/loaf-buffered.html | 28 +++++ .../tentative/loaf-event-blocking-duration.html | 30 +++++ .../tentative/loaf-event-listener.html | 44 +++++++ .../tentative/loaf-first-ui-event.html | 81 +++++++++++++ .../long-animation-frame/tentative/loaf-idle.html | 36 ++++++ .../tentative/loaf-iframe-crossorigin.html | 27 +++++ .../tentative/loaf-iframe-same-origin.html | 35 ++++++ .../tentative/loaf-iframe-self.html | 31 +++++ .../tentative/loaf-pause-duration.html | 30 +++++ .../long-animation-frame/tentative/loaf-popup.html | 25 ++++ .../tentative/loaf-promise.html | 52 ++++++++ .../tentative/loaf-script-block.html | 77 ++++++++++++ .../tentative/loaf-script-nested-callback.html | 41 +++++++ .../tentative/loaf-script-window-attribution.html | 61 ++++++++++ .../tentative/loaf-source-location-redirect.html | 95 +++++++++++++++ .../tentative/loaf-source-location.html | 57 +++++++++ .../tentative/loaf-stream-source-location.html | 26 ++++ .../tentative/loaf-stream.html | 39 ++++++ .../tentative/loaf-supportedEntryTypes.html | 22 ++++ .../tentative/loaf-timeline.html | 27 +++++ .../tentative/loaf-toJSON.html | 46 ++++++++ .../tentative/loaf-ui-event-render-start.html | 46 ++++++++ .../tentative/loaf-user-callback.html | 56 +++++++++ .../tentative/loaf-visibility.html | 26 ++++ .../tentative/loaf-window-only.worker.js | 11 ++ .../tentative/resources/busy.js | 4 + .../tentative/resources/event-generates-loaf.js | 10 ++ .../tentative/resources/loaf-after-callback.js | 7 ++ .../resources/loaf-in-microtask-after-callback.js | 7 ++ .../tentative/resources/promise-generates-loaf.js | 4 + .../tentative/resources/raf-generates-loaf.js | 5 + .../resources/stream-promise-generates-loaf.js | 12 ++ .../tentative/resources/utils.js | 131 +++++++++++++++++++++ 36 files changed, 1353 insertions(+) create mode 100644 testing/web-platform/tests/long-animation-frame/META.yml create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-basic.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-blocking-duration.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-buffered.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-event-blocking-duration.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-event-listener.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-first-ui-event.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-idle.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-crossorigin.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-same-origin.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-self.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-pause-duration.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-popup.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-promise.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-script-block.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-script-nested-callback.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-script-window-attribution.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-source-location-redirect.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-source-location.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-stream-source-location.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-stream.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-supportedEntryTypes.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-timeline.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-toJSON.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-ui-event-render-start.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-user-callback.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-visibility.html create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/loaf-window-only.worker.js create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/resources/busy.js create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/resources/event-generates-loaf.js create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/resources/loaf-after-callback.js create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/resources/loaf-in-microtask-after-callback.js create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/resources/promise-generates-loaf.js create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/resources/raf-generates-loaf.js create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/resources/stream-promise-generates-loaf.js create mode 100644 testing/web-platform/tests/long-animation-frame/tentative/resources/utils.js (limited to 'testing/web-platform/tests/long-animation-frame') diff --git a/testing/web-platform/tests/long-animation-frame/META.yml b/testing/web-platform/tests/long-animation-frame/META.yml new file mode 100644 index 0000000000..769c325aee --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/META.yml @@ -0,0 +1,2 @@ +suggested_reviewers: + - noamr diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-basic.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-basic.html new file mode 100644 index 0000000000..c6d3f8e32a --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-basic.html @@ -0,0 +1,57 @@ + + +Long Animation Frame Timing: basic + + + + + + +

Long Animation Frame: basic

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-blocking-duration.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-blocking-duration.html new file mode 100644 index 0000000000..e56a98649e --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-blocking-duration.html @@ -0,0 +1,65 @@ + + +Long Animation Frame Timing: basic + + + + + + +

Long Animation Frame: blocking duration

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-buffered.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-buffered.html new file mode 100644 index 0000000000..1a07036b15 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-buffered.html @@ -0,0 +1,28 @@ + + +Long Animation Frame Timing: basic + + + + + + +

Long Animation Frame: buffered

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-event-blocking-duration.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-event-blocking-duration.html new file mode 100644 index 0000000000..ed31244a1d --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-event-blocking-duration.html @@ -0,0 +1,30 @@ + + +Long Animation Frame Timing: blocking duration with events + + + + + + + + + +

Long Animation Frame: blocking duration with events

+
+ + + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-event-listener.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-event-listener.html new file mode 100644 index 0000000000..f866a1dfd8 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-event-listener.html @@ -0,0 +1,44 @@ + + +Long Animation Frame Timing: basic + + + + + + +

Long Animation Frame: event handlers

+
+ + 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 @@ + + +Long Animation Frame Timing: first UI Event + + + + + + + + + +

Long Animation Frame: First UI Event

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-idle.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-idle.html new file mode 100644 index 0000000000..bc9f910bb1 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-idle.html @@ -0,0 +1,36 @@ + + +Long Animation Frame Timing: requestIdleCallback + + + + + + +

Long Animation Frame: requestIdleCallback

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-crossorigin.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-crossorigin.html new file mode 100644 index 0000000000..16ecfd7017 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-crossorigin.html @@ -0,0 +1,27 @@ + + +Long Animation Frame Timing: iframes (cross-origin) + + + + + + + + +
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-same-origin.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-same-origin.html new file mode 100644 index 0000000000..65dc89f29a --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-same-origin.html @@ -0,0 +1,35 @@ + + +Long Animation Frame Timing: iframes (same-origin) + + + + + + + + +
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-self.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-self.html new file mode 100644 index 0000000000..7511ff1072 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-iframe-self.html @@ -0,0 +1,31 @@ + + +Long Animation Frame Timing: iframes (self) + + + + + + + + +
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-pause-duration.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-pause-duration.html new file mode 100644 index 0000000000..a4181239d4 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-pause-duration.html @@ -0,0 +1,30 @@ + + +Long Animation Frame Timing: pause + + + + + + +

Long Animation Frame: pause

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-popup.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-popup.html new file mode 100644 index 0000000000..3f9758953e --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-popup.html @@ -0,0 +1,25 @@ + + +Long Animation Frame Timing: popups + + + + + + + + +
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-promise.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-promise.html new file mode 100644 index 0000000000..5ead569c8a --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-promise.html @@ -0,0 +1,52 @@ + + +Long Animation Frame Timing: promise resolvers + + + + + + + +

Long Animation Frame: promise resolvers

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-script-block.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-script-block.html new file mode 100644 index 0000000000..759b31f9a1 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-script-block.html @@ -0,0 +1,77 @@ + + +Long Animation Frame Timing: script blocks + + + + + + + +

Long Animation Frame: script blocks

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-script-nested-callback.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-script-nested-callback.html new file mode 100644 index 0000000000..8d1304fc80 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-script-nested-callback.html @@ -0,0 +1,41 @@ + + +Long Animation Frame Timing: nested scripts + + + + + + + +

Long Animation Frame: nested scripts

+
+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-script-window-attribution.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-script-window-attribution.html new file mode 100644 index 0000000000..0b8f45bed0 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-script-window-attribution.html @@ -0,0 +1,61 @@ + + + +Long Animation Frame Timing: window attribution + + + + + + + + +
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-source-location-redirect.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-source-location-redirect.html new file mode 100644 index 0000000000..c0bb96b1ec --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-source-location-redirect.html @@ -0,0 +1,95 @@ + + +Long Animation Frame Timing: source location should not expose cross-origin redirects + + + + + + + + +

Long Animation Frame: source location with cross-origin redirects

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-source-location.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-source-location.html new file mode 100644 index 0000000000..51e8565644 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-source-location.html @@ -0,0 +1,57 @@ + + +Long Animation Frame Timing: source location extraction + + + + + + +

Long Animation Frame: source location extraction

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-stream-source-location.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-stream-source-location.html new file mode 100644 index 0000000000..0fd30859d7 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-stream-source-location.html @@ -0,0 +1,26 @@ + + +Long Animation Frame Timing: source location extraction for streams + + + + + + +

Long Animation Frame: source location extraction for streams

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-stream.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-stream.html new file mode 100644 index 0000000000..e35bc2f9aa --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-stream.html @@ -0,0 +1,39 @@ + + +Long Animation Frame Timing: stream promise resolvers + + + + + + + +

Long Animation Frame: stream promise resolvers

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-supportedEntryTypes.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-supportedEntryTypes.html new file mode 100644 index 0000000000..efa01481fa --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-supportedEntryTypes.html @@ -0,0 +1,22 @@ + + +Long Animation Frame Timing: supportedEntryTypes + + + + + +

Long Animation Frame: supportedEntryTypes

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-timeline.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-timeline.html new file mode 100644 index 0000000000..c434a26ef8 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-timeline.html @@ -0,0 +1,27 @@ + + +Long Animation Frame Timing: basic + + + + + + +

Long Animation Frame: basic

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-toJSON.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-toJSON.html new file mode 100644 index 0000000000..5b249e6972 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-toJSON.html @@ -0,0 +1,46 @@ + + + + + + + + + + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-ui-event-render-start.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-ui-event-render-start.html new file mode 100644 index 0000000000..01d50d47e9 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-ui-event-render-start.html @@ -0,0 +1,46 @@ + + +Long Animation Frame Timing: UI events and renderStart + + + + + + + + + +

Long Animation Frame: UI events and renderStart

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-user-callback.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-user-callback.html new file mode 100644 index 0000000000..3d868af87f --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-user-callback.html @@ -0,0 +1,56 @@ + + +Long Animation Frame Timing: basic + + + + + + +

Long Animation Frame: user callbacks

+
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-visibility.html b/testing/web-platform/tests/long-animation-frame/tentative/loaf-visibility.html new file mode 100644 index 0000000000..97038e3073 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-visibility.html @@ -0,0 +1,26 @@ + + + +Long Animation Frame Timing: iframes + + + + + + + + + +
+ + diff --git a/testing/web-platform/tests/long-animation-frame/tentative/loaf-window-only.worker.js b/testing/web-platform/tests/long-animation-frame/tentative/loaf-window-only.worker.js new file mode 100644 index 0000000000..c1f0439c4b --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/loaf-window-only.worker.js @@ -0,0 +1,11 @@ +importScripts("/resources/testharness.js"); + +test(() => { + assert_false(PerformanceObserver.supportedEntryTypes.includes("long-animation-frame")); +}, 'PerformanceObserver should not include "long-animation-frame" in workers'); + +test(() => { + assert_false("PerformanceLongAnimationFrameTiming" in self); +}, 'PerformanceLongAnimationFrameTiming should not be exposed in workers'); + +done(); diff --git a/testing/web-platform/tests/long-animation-frame/tentative/resources/busy.js b/testing/web-platform/tests/long-animation-frame/tentative/resources/busy.js new file mode 100644 index 0000000000..9d761b6de5 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/resources/busy.js @@ -0,0 +1,4 @@ +(() => { + const deadline = performance.now() + 360; + while (performance.now() < deadline) {} +})(); diff --git a/testing/web-platform/tests/long-animation-frame/tentative/resources/event-generates-loaf.js b/testing/web-platform/tests/long-animation-frame/tentative/resources/event-generates-loaf.js new file mode 100644 index 0000000000..fe7c3eca2b --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/resources/event-generates-loaf.js @@ -0,0 +1,10 @@ +(() => { + const xhr = new XMLHttpRequest(); + xhr.open('GET', '/common/dummy.xml'); + xhr.addEventListener('load', () => { + const deadline = performance.now() + 360; + while (performance.now() < deadline) { + } + }); + xhr.send(); +})(); diff --git a/testing/web-platform/tests/long-animation-frame/tentative/resources/loaf-after-callback.js b/testing/web-platform/tests/long-animation-frame/tentative/resources/loaf-after-callback.js new file mode 100644 index 0000000000..d9ac74ccf4 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/resources/loaf-after-callback.js @@ -0,0 +1,7 @@ +(function() { + busy_wait(60); + new URLSearchParams([["a", "hello"]]).forEach((value, key) => { + document.querySelector("#dummy").innerText += value; + }); + busy_wait(); +})(); diff --git a/testing/web-platform/tests/long-animation-frame/tentative/resources/loaf-in-microtask-after-callback.js b/testing/web-platform/tests/long-animation-frame/tentative/resources/loaf-in-microtask-after-callback.js new file mode 100644 index 0000000000..c73b604f6d --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/resources/loaf-in-microtask-after-callback.js @@ -0,0 +1,7 @@ +(function() { + busy_wait(60); + Promise.resolve().then(busy_wait); + new URLSearchParams([["a", "hello"]]).forEach((value, key) => { + document.querySelector("#dummy").innerText += value; + }); +})(); diff --git a/testing/web-platform/tests/long-animation-frame/tentative/resources/promise-generates-loaf.js b/testing/web-platform/tests/long-animation-frame/tentative/resources/promise-generates-loaf.js new file mode 100644 index 0000000000..53369f7226 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/resources/promise-generates-loaf.js @@ -0,0 +1,4 @@ +fetch("/common/dummy.xml").then(() => { + const deadline = performance.now() + 360; + while (performance.now() < deadline) {} +}); diff --git a/testing/web-platform/tests/long-animation-frame/tentative/resources/raf-generates-loaf.js b/testing/web-platform/tests/long-animation-frame/tentative/resources/raf-generates-loaf.js new file mode 100644 index 0000000000..b7544af4e5 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/resources/raf-generates-loaf.js @@ -0,0 +1,5 @@ +requestAnimationFrame(() => { + const deadline = performance.now() + 360; + while (performance.now() < deadline) { + } +}); diff --git a/testing/web-platform/tests/long-animation-frame/tentative/resources/stream-promise-generates-loaf.js b/testing/web-platform/tests/long-animation-frame/tentative/resources/stream-promise-generates-loaf.js new file mode 100644 index 0000000000..35e7920bb2 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/resources/stream-promise-generates-loaf.js @@ -0,0 +1,12 @@ +(async() => { + const response = await fetch("/common/dummy.xml"); + const {readable, writable} = new TransformStream({ + start() {}, + transform() { + const deadline = performance.now() + 360; + while (performance.now() < deadline) {} + } + }); + response.body.pipeTo(writable); + await readable.getReader().read(); +})(); diff --git a/testing/web-platform/tests/long-animation-frame/tentative/resources/utils.js b/testing/web-platform/tests/long-animation-frame/tentative/resources/utils.js new file mode 100644 index 0000000000..aa537d39a7 --- /dev/null +++ b/testing/web-platform/tests/long-animation-frame/tentative/resources/utils.js @@ -0,0 +1,131 @@ +const windowLoaded = new Promise(resolve => window.addEventListener('load', resolve)); +setup(() => + assert_implements(window.PerformanceLongAnimationFrameTiming, + 'Long animation frames are not supported.')); + +const very_long_frame_duration = 360; +const no_long_frame_timeout = very_long_frame_duration * 2; +const waiting_for_long_frame_timeout = very_long_frame_duration * 10; + +function loaf_promise(t) { + return new Promise(resolve => { + const observer = new PerformanceObserver(entries => { + const entry = entries.getEntries()[0]; + // TODO: understand why we need this 5ms epsilon. + if (entry.duration > very_long_frame_duration - 5) { + observer.disconnect(); + resolve(entry); + } + }); + + t.add_cleanup(() => observer.disconnect()); + + observer.observe({entryTypes: ['long-animation-frame']}); + }); +} + +function busy_wait(ms_delay = very_long_frame_duration) { + const deadline = performance.now() + ms_delay; + while (performance.now() < deadline) {} +} + +async function expect_long_frame(cb, t) { + await windowLoaded; + await new Promise(resolve => t.step_timeout(resolve, 0)); + const timeout = new Promise((resolve, reject) => + t.step_timeout(() => resolve("timeout"), waiting_for_long_frame_timeout)); + const receivedLongFrame = loaf_promise(t); + await cb(t); + const entry = await Promise.race([ + receivedLongFrame, + timeout + ]); + return entry; +} + +async function expect_long_frame_with_script(cb, predicate, t) { + for (let i = 0; i < 10; ++i) { + const entry = await expect_long_frame(cb, t); + if (entry === "timeout" || !entry.scripts.length) + continue; + for (const script of entry.scripts) { + if (predicate(script, entry)) + return [entry, script]; + } + } + + return []; +} + +async function expect_no_long_frame(cb, t) { + await windowLoaded; + for (let i = 0; i < 5; ++i) { + const receivedLongFrame = loaf_promise(t); + await cb(); + const result = await Promise.race([receivedLongFrame, + new Promise(resolve => t.step_timeout(() => resolve("timeout"), + no_long_frame_timeout))]); + if (result === "timeout") + return false; + } + + throw new Error("Consistently creates long frame"); +} + +async function prepare_exec_iframe(t, origin) { + const iframe = document.createElement("iframe"); + t.add_cleanup(() => iframe.remove()); + const url = new URL("/common/dispatcher/remote-executor.html", origin); + const uuid = token(); + url.searchParams.set("uuid", uuid); + iframe.src = url.href; + document.body.appendChild(iframe); + await new Promise(resolve => iframe.addEventListener("load", resolve)); + return [new RemoteContext(uuid), iframe]; +} + + +async function prepare_exec_popup(t, origin) { + const url = new URL("/common/dispatcher/remote-executor.html", origin); + const uuid = token(); + url.searchParams.set("uuid", uuid); + const popup = window.open(url); + t.add_cleanup(() => popup.close()); + return [new RemoteContext(uuid), popup]; +} +function test_loaf_script(cb, invoker, invokerType, label) { + promise_test(async t => { + let [entry, script] = []; + [entry, script] = await expect_long_frame_with_script(cb, + script => ( + script.invokerType === invokerType && + script.invoker.startsWith(invoker) && + script.duration >= very_long_frame_duration), t); + + assert_true(!!entry, "Entry detected"); + assert_greater_than_equal(script.duration, very_long_frame_duration); + assert_greater_than_equal(entry.duration, script.duration); + assert_greater_than_equal(script.executionStart, script.startTime); + assert_greater_than_equal(script.startTime, entry.startTime) + assert_equals(script.window, window); + assert_equals(script.forcedStyleAndLayoutDuration, 0); + assert_equals(script.windowAttribution, "self"); +}, `LoAF script: ${invoker} ${invokerType},${label ? ` ${label}` : ''}`); + +} + +function test_self_user_callback(cb, invoker, label) { + test_loaf_script(cb, invoker, "user-callback", label); +} + +function test_self_event_listener(cb, invoker) { + test_loaf_script(cb, invoker, "event-listener"); +} + +function test_promise_script(cb, resolve_or_reject, invoker, label) { + test_loaf_script(cb, invoker, `${resolve_or_reject}-promise`, label); +} + +function test_self_script_block(cb, invoker, type) { + test_loaf_script(cb, invoker, type); +} -- cgit v1.2.3