Skip to content

Commit

Permalink
WIP - Prototype auto sizes for lazy-loaded img
Browse files Browse the repository at this point in the history
Spec PR:
whatwg/html#8008

WPT tests PR:
#34427

R=pdr

Bug: 1359051
Change-Id: I8e9bc836e9582a9209db53d55e0edc96f90499f2
  • Loading branch information
tcaptan-cr authored and chromium-wpt-export-bot committed May 19, 2023
1 parent 02400d3 commit fee3385
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!doctype html>
<title>Auto sizes rendering</title>
<link rel="help" href="specLinkTBDhttps://drafts.csswg.org/css-images-4/#image-set-notation">
<meta name="assert" content="auto sizes rendering">
<img
src="/images/green.png"
width="100px"
>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html class="reftest-wait">
<title>Auto sizes dynamic rendering</title>
<link rel="help" href="specLinkTBD">
<link rel="match" href="reference/sizes-auto-rendering-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<meta name="assert" content="auto sizes dynamic rendering">
<img
id="testImg"
loading="lazy"
srcset="
/images/fail.gif 200w,
/images/green.png 100w,
/images/red.png 50w
"
sizes="auto"
width="50px"
>
<script>
function secondImageLoaded() {
waitForAtLeastOneFrame().then(takeScreenshot);
}

function firstImageLoaded() {
testImg.addEventListener('load', secondImageLoaded);
testImg.style.width = '100px';
}

testImg.addEventListener('load', firstImageLoaded, {once: true});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>
<html class="reftest-wait">
<title>Auto sizes rendering</title>
<link rel="help" href="specLinkTBD">
<link rel="match" href="reference/sizes-auto-rendering-ref.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<meta name="assert" content="auto sizes rendering">
<img
id="testImg"
loading="lazy"
srcset="
/images/fail.gif 50w,
/images/green.png 100w,
/images/red.png 200w
"
sizes="auto"
width="100px"
>
<script>
function imageLoaded() {
waitForAtLeastOneFrame().then(takeScreenshot);
}

testImg.addEventListener('load', imageLoaded);
</script>

0 comments on commit fee3385

Please sign in to comment.