Bug 732178. Set up the image cache validator before the CORS listener. r=joe,sicking
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 02 Mar 2012 00:13:54 -0500
changeset 88333 593ae548729340f0242f98468a6823acde8da0d1
parent 88332 c30b6943dc98e8b2d24f76fba20764eefbfb109a
child 88334 b1eb49737d05a4d89ac681a91fa0075a7846829c
push id157
push userMs2ger@gmail.com
push dateWed, 07 Mar 2012 19:27:10 +0000
reviewersjoe, sicking
bugs732178
milestone13.0a1
Bug 732178. Set up the image cache validator before the CORS listener. r=joe,sicking
image/src/imgLoader.cpp
--- a/image/src/imgLoader.cpp
+++ b/image/src/imgLoader.cpp
@@ -1281,29 +1281,32 @@ bool imgLoader::ValidateRequestWithNewCh
     if (!progressproxy)
       return false;
 
     nsRefPtr<imgCacheValidator> hvc =
       new imgCacheValidator(progressproxy, request, aCX, forcePrincipalCheck);
 
     nsCOMPtr<nsIStreamListener> listener = hvc.get();
 
+    // We must set the notification callbacks before setting up the
+    // CORS listener, because that's also interested inthe
+    // notification callbacks.
+    newChannel->SetNotificationCallbacks(hvc);
+
     if (aCORSMode != imgIRequest::CORS_NONE) {
       bool withCredentials = aCORSMode == imgIRequest::CORS_USE_CREDENTIALS;
       nsCOMPtr<nsIStreamListener> corsproxy =
         new nsCORSListenerProxy(hvc, aLoadingPrincipal, newChannel, withCredentials, &rv);
       if (NS_FAILED(rv)) {
         return false;
       }
 
       listener = corsproxy;
     }
 
-    newChannel->SetNotificationCallbacks(hvc);
-
     request->mValidator = hvc;
 
     imgRequestProxy* proxy = static_cast<imgRequestProxy*>
                                (static_cast<imgIRequest*>(req.get()));
 
     // We will send notifications from imgCacheValidator::OnStartRequest().
     // In the mean time, we must defer notifications because we are added to
     // the imgRequest's proxy list, and we can get extra notifications