Skip to content

Commit b6aeb73

Browse files
Fix timing of checking currentSrc in sizes-auto-resize-observer-removes-auto.html.
Differential Revision: https://phabricator.services.mozilla.com/D297354 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=2035695 gecko-commit: c427419afb57d1a0c85ff47d331ef30c05488276 gecko-commit-git: d284551d9e4dd8a270dddd0199ea50b4acdbd65a gecko-reviewers: dom-core, smaug
1 parent 3248b40 commit b6aeb73

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

html/semantics/embedded-content/the-img-element/sizes/sizes-auto-resize-observer-removes-auto.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=2033652">
77
<script src="/resources/testharness.js"></script>
88
<script src="/resources/testharnessreport.js"></script>
9-
<img id="img" srcset="/images/green-1x1.png 1w, /images/green-16x16.png 16w, /images/green-256x256.png 256w"
10-
sizes="1px" style="width:16px;" loading="lazy">
9+
<img id="img" sizes="1px" style="width:16px;" loading="lazy">
1110
<script>
1211
"use strict";
1312
/*
@@ -17,7 +16,9 @@
1716
still be notified for the now not sizes=auto image.
1817
*/
1918
promise_test(async t => {
20-
await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));
19+
let waitForLoad = new Promise(r => img.addEventListener('load', r, {once: true}));
20+
img.srcset = "/images/green-1x1.png 1w, /images/green-16x16.png 16w, /images/green-256x256.png 256w";
21+
await waitForLoad;
2122
let resizeObserved = false;
2223
let observer = new ResizeObserver(() => {
2324
if (img.style.width === "1px") {
@@ -30,12 +31,14 @@
3031
let currentSrc = () => new URL(img.currentSrc).pathname;
3132
assert_equals(currentSrc(), "/images/green-1x1.png",
3233
"image's source should be set based on sizes=1px");
34+
waitForLoad = new Promise(r => img.addEventListener('load', r, {once: true}));
3335
img.sizes = "auto";
34-
await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));
36+
await waitForLoad;
3537
assert_equals(currentSrc(), "/images/green-16x16.png",
3638
"image's source should be set based on sizes=auto and content box width of 16px");
39+
waitForLoad = new Promise(r => img.addEventListener('load', r, {once: true}));
3740
img.style.width = "1px";
38-
await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));
41+
await waitForLoad;
3942
assert_true(resizeObserved, "ResizeObserver should have been notified of resize");
4043
assert_equals(currentSrc(), "/images/green-256x256.png",
4144
"image's source should be set based on sizes=256px from ResizeObserver");

0 commit comments

Comments
 (0)