Commit ee4b916b authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Treat a "not started" image resource in ImageLoader as "no resource"

When loading of images is disabled, ResourceFetcher will return an
ImageResource{,Content} whose status is "not started". Since this
resource will not get a "finished" notification, we didn't update the
<img> to show fallback content when the image is first requested.
Subsequent loads would yield the fallback correctly because the cached
resource was returned.

Add a case to ImageLoader::DoUpdateFromElement() to check for this case
and call NoImageResourceToLoad().

Bug: 982603
Change-Id: I6377f87a45745c364f92ceb0e8c4dabd4fbc1b9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1695549Reviewed-by: default avatarHiroshige Hayashizaki <hiroshige@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#676532}
parent ba81ae46
...@@ -693,6 +693,13 @@ void ImageLoader::DoUpdateFromElement( ...@@ -693,6 +693,13 @@ void ImageLoader::DoUpdateFromElement(
new_image_content == old_image_content) { new_image_content == old_image_content) {
ToLayoutImage(element_->GetLayoutObject())->IntrinsicSizeChanged(); ToLayoutImage(element_->GetLayoutObject())->IntrinsicSizeChanged();
} else { } else {
// Loading didn't start (loading of images was disabled). We show fallback
// contents here, while we don't dispatch an 'error' event etc., because
// spec-wise the image remains in the "Unavailable" state.
if (new_image_content &&
new_image_content->GetContentStatus() == ResourceStatus::kNotStarted)
NoImageResourceToLoad();
if (pending_load_event_.IsActive()) if (pending_load_event_.IsActive())
pending_load_event_.Cancel(); pending_load_event_.Cancel();
......
<!DOCTYPE html>
<title>Fallback content should be shown when image loading is disabled (reference)</title>
<img src="not-resources/mu.png" alt="Chair spinning">
<!DOCTYPE html>
<title>Fallback content should be shown when image loading is disabled</title>
<script>
if (window.internals)
internals.settings.setLoadsImagesAutomatically(false);
</script>
<body></body>
<script>
let image = new Image();
image.src = "resources/mu.png?" + Math.random();
image.alt = "Chair spinning";
document.body.appendChild(image);
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment