Index: Source/core/loader/ImageLoader.cpp |
diff --git a/Source/core/loader/ImageLoader.cpp b/Source/core/loader/ImageLoader.cpp |
index c89b49fc21096ea00e9107972d5d4a97d6f7eba7..825907d527ce46dd872181f1fbc1262693728a45 100644 |
--- a/Source/core/loader/ImageLoader.cpp |
+++ b/Source/core/loader/ImageLoader.cpp |
@@ -120,6 +120,7 @@ ImageLoader::ImageLoader(Element* element) |
, m_imageComplete(true) |
, m_loadingImageDocument(false) |
, m_elementIsProtected(false) |
+ , m_suppressErrorEvents(false) |
, m_highPriorityClientCount(0) |
{ |
WTF_LOG(Timers, "new ImageLoader %p", this); |
@@ -319,6 +320,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up |
void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, LoadType loadType) |
{ |
AtomicString imageSourceURL = m_element->imageSourceURL(); |
+ m_suppressErrorEvents = (updateBehavior == UpdateSizeChanged); |
if (updateBehavior == UpdateIgnorePreviousError) |
clearFailedLoadURL(); |
@@ -386,8 +388,12 @@ void ImageLoader::notifyFinished(Resource* resource) |
loadEventSender().cancelEvent(this); |
m_hasPendingLoadEvent = false; |
- m_hasPendingErrorEvent = true; |
- errorEventSender().dispatchEventSoon(this); |
+ // The error event should not fire if the image data update is a result of environment change. |
+ // https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element:the-img-element-55 |
+ if (!m_suppressErrorEvents) { |
+ m_hasPendingErrorEvent = true; |
+ errorEventSender().dispatchEventSoon(this); |
+ } |
// Only consider updating the protection ref-count of the Element immediately before returning |
// from this function as doing so might result in the destruction of this ImageLoader. |