Commit 047322c2 authored by yoav@yoav.ws's avatar yoav@yoav.ws

Error event shouldn't fire when image is updated on environment changes.

When environment changes triggered an image load, the error event was
wrongfully triggered. This is the wrong behavior for Web compat and
it made related tests flaky.
This CL fixes that.

BUG=410268,411672

Review URL: https://codereview.chromium.org/654253003

git-svn-id: svn://svn.chromium.org/blink/trunk@184917 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 12505dd2
CONSOLE MESSAGE: line 14: Error triggerred
CONSOLE MESSAGE: line 14: Error triggerred
......@@ -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);
......@@ -320,6 +321,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();
......@@ -387,8 +389,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.
......
......@@ -186,6 +186,7 @@ private:
bool m_imageComplete : 1;
bool m_loadingImageDocument : 1;
bool m_elementIsProtected : 1;
bool m_suppressErrorEvents : 1;
unsigned m_highPriorityClientCount;
};
......
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