Bug 1297156: Fire an error event to xul:image elements when the attempt to load an image fails synchronously. draft
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 11 Apr 2018 13:00:56 -0700
changeset 780716 4acfb683a03bbf3c82c0544d661f57e40ee61772
parent 780715 81bfd5cadb33ac9544a37de22c0980d22eb91ce7
child 780717 934a84c5785365d2646d8b09c3796898a07b160d
push id106099
push userdtownsend@mozilla.com
push dateWed, 11 Apr 2018 20:47:47 +0000
bugs1297156
milestone61.0a1
Bug 1297156: Fire an error event to xul:image elements when the attempt to load an image fails synchronously. When the attempt to load an image returns a failure we need to dispatch an error event to the xul element. MozReview-Commit-ID: BpWMTy4peOG
layout/xul/nsImageBoxFrame.cpp
--- a/layout/xul/nsImageBoxFrame.cpp
+++ b/layout/xul/nsImageBoxFrame.cpp
@@ -253,17 +253,19 @@ nsImageBoxFrame::UpdateImage()
                                                 requestContextID,
                                                 doc->GetDocumentURI(),
                                                 doc->GetReferrerPolicy(),
                                                 mListener, mLoadFlags,
                                                 EmptyString(),
                                                 getter_AddRefs(mImageRequest),
                                                 contentPolicyType);
 
-        if (NS_SUCCEEDED(rv) && mImageRequest) {
+        if (NS_FAILED(rv)) {
+          FireImageDOMEvent(mContent, eLoadError);
+        } else if (mImageRequest) {
           nsLayoutUtils::RegisterImageRequestIfAnimated(presContext,
                                                         mImageRequest,
                                                         &mRequestRegistered);
         }
       }
     }
   } else {
     // Only get the list-style-image if we aren't being drawn