Skip to content

Commit

Permalink
CV: Add content attribute handling + test
Browse files Browse the repository at this point in the history
This patch adds a content attribute parsing and a wpt test for
contentvisibilityautostatechange event

[email protected]

Change-Id: Iae610a794477d3ca0b346b752b489cd101399fcc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5570779
Commit-Queue: Vladimir Levin <[email protected]>
Reviewed-by: Khushal Sagar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1305905}
  • Loading branch information
vmpstr authored and chromium-wpt-export-bot committed May 24, 2024
1 parent cceaf36 commit a92b1b3
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@
.auto { content-visibility: auto; }
</style>

<script>
let contentattrfired = false;

function contentattrDidFire() {
contentattrfired = true;
}

</script>

<div id=upper></div>
<div id=attrtest></div>
<div id=contentattrtest oncontentvisibilityautostatechange="contentattrDidFire()" class=auto></div>
<div class=spacer></div>
<div id=middle></div>
<div class=spacer></div>
Expand All @@ -40,6 +51,18 @@
upper.classList.add("auto");
}), "ContentVisibilityAutoStateChange fires when relevant element gains `content-visibility:auto`");

promise_test(t => new Promise(async (resolve, reject) => {
let shouldSkip = false;
const listener = (e) => {
if (!e.skipped)
resolve();
};

attrtest.oncontentvisibilityautostatechange = listener;
t.add_cleanup(() => { attrtest.oncontentvisibilityautostatechange = () => {} });
attrtest.classList.add("auto");
}), "ContentVisibilityAutoStateChange fires when relevant element gains `content-visibility:auto` (oncontentvisibilityautostatechange syntax)");

promise_test(t => new Promise(async (resolve, reject) => {
let shouldSkip = false;
const listener = (e) => {
Expand All @@ -54,6 +77,14 @@
lower.classList.add("auto");
}), "ContentVisibilityAutoStateChange fires when not relevant element gains `content-visibility:auto`");

async_test(t => {
requestAnimationFrame(() => requestAnimationFrame(() => {
t.step(() => assert_true(contentattrfired, "contentattrfired"));
t.done();
}));

}, "ContentVisibilityAutoStateChange content attribute test");

promise_test(t => new Promise(async (resolve, reject) => {
await new Promise((waited, _) => {
requestAnimationFrame(() => requestAnimationFrame(waited));
Expand Down

0 comments on commit a92b1b3

Please sign in to comment.