diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/layout-instability/move-distance-clamped.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/layout-instability/move-distance-clamped.html')
-rw-r--r-- | testing/web-platform/tests/layout-instability/move-distance-clamped.html | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/testing/web-platform/tests/layout-instability/move-distance-clamped.html b/testing/web-platform/tests/layout-instability/move-distance-clamped.html new file mode 100644 index 0000000000..5854fe08d1 --- /dev/null +++ b/testing/web-platform/tests/layout-instability/move-distance-clamped.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<title>Layout Instability: distance fraction not more than 1.0</title> +<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/test-adapter.js"></script> +<script src="resources/util.js"></script> +<style> +body { margin: 0; } +#shifter { + position: relative; + width: 100vw; + height: 100vh; + left: -2000vw; + top: -2000vh; + background: blue; +} +</style> +<div id="shifter"></div> +<script> + +promise_test(async () => { + const watcher = new ScoreWatcher; + + // Wait for the initial render to complete. + await waitForAnimationFrames(2); + + // Modify the position of the div. + document.querySelector("#shifter").style = "left: 0; top: 0"; + + const docElement = document.documentElement; + const viewWidth = docElement.clientWidth; + const viewHeight = docElement.clientHeight; + + // An element the size of the viewport has shifted by a huge distance, but + // the move distance is effectively the viewport width or height (whichever + // is larger) as the distance fraction is limited to a maximum of 1.0. + const expectedScore = computeExpectedScore( + viewWidth * viewHeight, + Math.max(viewWidth, viewHeight)); + + // Observer fires after the frame is painted. + cls_expect(watcher, {score: 0}); + await watcher.promise; + cls_expect(watcher, {score: expectedScore}); +}, "Distance fraction not more than 1.0."); + +</script> |