Skip to content

Commit

Permalink
CV: Add a test for first visibility determination (web-platform-tests…
Browse files Browse the repository at this point in the history
…#41205)

This adds a test which directly tests the changes in
whatwg/html#9312

[email protected]

Change-Id: I2108e67d0444220cb75e43121dbe6076052a2b5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4725605
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Vladimir Levin <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1176127}

Co-authored-by: Vladimir Levin <[email protected]>
  • Loading branch information
2 people authored and Lightning00Blade committed Dec 11, 2023
1 parent 210bfb5 commit fdca053
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!doctype HTML>
<html>
<meta charset="utf8">
<title>Content Visibility: first visibility determination happens before resize observer.</title>
<link rel="author" title="Vladimir Levin" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-contain/#content-visibility">
<meta name="assert" content="first visibility determination happens before resize observer">

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<style>
#target {
content-visibility: auto;
contain-intrinsic-size: 10px;
}
#child {
height: 100px;
}
</style>

<div id=container></div>

<script>
promise_test(t => new Promise(async (resolve, reject) => {
requestAnimationFrame(() => {
let target = document.createElement("div");
target.id = "target";

let child = document.createElement("div");
child.id = "child";
target.appendChild(child);

const resizeObserver = new ResizeObserver((entries) => {
for (const entry of entries) {
if (entry.contentBoxSize) {
if (entry.contentBoxSize[0].blockSize == 100) {
resolve();
return;
} else {
reject(`unexpected size ${entry.contentBoxSize[0].blockSize}`);
return;
}
}
}
reject("no content boxes or no entries");
});

container.appendChild(target);
resizeObserver.observe(target);
});
}), "Target is sized and laid out before resize observer");
</script>

0 comments on commit fdca053

Please sign in to comment.