Skip to content

Commit

Permalink
Force DisplayLocks in <img> Layout APIs
Browse files Browse the repository at this point in the history
Without this patch, width, height, x, and y return zero due to layout
being skipped for DisplayLocking.

Bug: 1247417
Change-Id: I29f34a20d49be03ac810186ca65983b6e43e4391
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3145934
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#919323}
  • Loading branch information
josepharhar authored and chromium-wpt-export-bot committed Sep 8, 2021
1 parent bf08701 commit 00eaeb7
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions css/css-contain/content-visibility/content-visibility-img.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1247417">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<style>
div {
content-visibility: hidden;
}
</style>
<div id=container1></div>
<div id=container2></div>
<div id=container3></div>
<div id=container4></div>

<script>
promise_test(async () => {
const img1 = document.createElement('img');
container1.appendChild(img1);
const img1Load = new Promise(resolve => img1.onload = resolve);
img1.src = 'resources/dice.png';
await img1Load;
assert_not_equals(img1.height, 0, 'height');

const img2 = document.createElement('img');
container2.appendChild(img2);
const img2Load = new Promise(resolve => img2.onload = resolve);
img2.src = 'resources/dice.png';
await img2Load;
assert_not_equals(img2.width, 0, 'width');

const img3 = document.createElement('img');
container3.appendChild(img3);
const img3Load = new Promise(resolve => img3.onload = resolve);
img3.src = 'resources/dice.png';
await img3Load;
assert_not_equals(img3.x, 0, 'x');

const img4 = document.createElement('img');
container4.appendChild(img4);
const img4Load = new Promise(resolve => img4.onload = resolve);
img4.src = 'resources/dice.png';
await img4Load;
assert_not_equals(img4.y, 0, 'y');

}, `c-v:hidden <img> layout APIs shouldn't return zero when accessed from script.`);
</script>

0 comments on commit 00eaeb7

Please sign in to comment.