Commit c4dfaf4d authored by Steve Kobes's avatar Steve Kobes Committed by Commit Bot

Add test for CLS distance fraction upper bound.

Change-Id: I794f216f0ab263667b7a5d130e38801bd2656f87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410821Reviewed-by: default avatarNicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807028}
parent 4cd7ee2d
<!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;
}
</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>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment