diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index ce3b5ff6e8c..0308e207e65 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -2019,8 +2019,7 @@ impl Window { } let mut images = self.pending_layout_images.borrow_mut(); - let nodes = images.entry(id).or_default(); - if !nodes.iter().any(|n| std::ptr::eq(&**n, &*node)) { + if !images.contains_key(&id) { let trusted_node = Trusted::new(&*node); let sender = self.register_image_cache_listener(id, move |response| { trusted_node @@ -2031,6 +2030,10 @@ impl Window { self.image_cache .add_listener(ImageResponder::new(sender, self.pipeline_id(), id)); + } + + let nodes = images.entry(id).or_default(); + if !nodes.iter().any(|n| std::ptr::eq(&**n, &*node)) { nodes.push(Dom::from_ref(&*node)); } } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 7a9b0919885..b6782318356 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -12873,6 +12873,13 @@ ] ] }, + "css-image-batch-callbacks.html": [ + "c449b8bab01d27a41bd1ba472ce6b38d0fa768b0", + [ + null, + {} + ] + ], "custom_auto_rooter.html": [ "3d6f04e85b27bcf957b273e04e4a80b75e714b2f", [ diff --git a/tests/wpt/mozilla/tests/mozilla/css-image-batch-callbacks.html b/tests/wpt/mozilla/tests/mozilla/css-image-batch-callbacks.html new file mode 100644 index 00000000000..c449b8bab01 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/css-image-batch-callbacks.html @@ -0,0 +1,22 @@ + + + + +
+