diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/layout-instability/idlharness.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/layout-instability/idlharness.html')
-rw-r--r-- | testing/web-platform/tests/layout-instability/idlharness.html | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/layout-instability/idlharness.html b/testing/web-platform/tests/layout-instability/idlharness.html new file mode 100644 index 0000000000..ea6efb27f8 --- /dev/null +++ b/testing/web-platform/tests/layout-instability/idlharness.html @@ -0,0 +1,50 @@ +<!doctype html> +<title>Layout Instability IDL tests</title> +<meta name="timeout" content="long"> +<link rel="help" href="https://wicg.github.io/layout-instability/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/WebIDLParser.js"></script> +<script src="/resources/idlharness.js"></script> +<script src="resources/util.js"></script> +<script> +'use strict'; + +idl_test( + ['layout-instability'], + ['performance-timeline', 'geometry', 'dom', 'hr-time'], + async (idl_array, t) => { + idl_array.add_objects({ + LayoutShift: ['layoutShift'], + LayoutShiftAttribution: ['layoutShiftAttribution'], + }); + + // If LayoutShift isn't supported, avoid the timeout below and just let the + // objects declared above be null. The tests will still fail, but we will + // consistently generate the same set of subtests on all platforms. + if (!PerformanceObserver || + !PerformanceObserver.supportedEntryTypes || + !PerformanceObserver.supportedEntryTypes.includes('layout-shift')) { + return; + } + + // Make sure that the image has initially been laid out, so that the movement + // later is counted as a layout shift. + await waitForAnimationFrames(2); + + self.layoutShift = await new Promise((resolve, reject) => { + const observer = new PerformanceObserver(entryList => { + resolve(entryList.getEntries()[0]); + }); + observer.observe({type: 'layout-shift', buffered: true}); + t.step_timeout(() => reject('Timed out waiting for LayoutShift entry'), 3000); + + // Move the image, to cause layout shift. + image.style.marginTop = '100px'; + }); + self.layoutShiftAttribution = layoutShift.sources[0]; + } +); +</script> + +<img id="image" src="/images/green-100x50.png"> |