Bug 1380341 - Fallback on the document's channel to check private browsing status if the load group has no load context. r=baku
authorAndrew Osmond <aosmond@mozilla.com>
Mon, 17 Jul 2017 09:38:10 -0400
changeset 369165 8843631f2926c3a655104c82aeb2c3a4764942f6
parent 369164 5d9a6384bf513139ca33f54825db4f035ebdbdab
child 369166 f763d7564c56c432f34e28fc8ccd1b768528cf01
push id92624
push useraosmond@gmail.com
push dateMon, 17 Jul 2017 13:38:30 +0000
treeherdermozilla-inbound@8843631f2926 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1380341
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1380341 - Fallback on the document's channel to check private browsing status if the load group has no load context. r=baku
dom/base/nsContentUtils.cpp
image/imgLoader.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -3583,17 +3583,24 @@ bool
 nsContentUtils::IsInPrivateBrowsing(nsIDocument* aDoc)
 {
   if (!aDoc) {
     return false;
   }
 
   nsCOMPtr<nsILoadGroup> loadGroup = aDoc->GetDocumentLoadGroup();
   if (loadGroup) {
-    return IsInPrivateBrowsing(loadGroup);
+    nsCOMPtr<nsIInterfaceRequestor> callbacks;
+    loadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks));
+    if (callbacks) {
+      nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(callbacks);
+      if (loadContext) {
+        return loadContext->UsePrivateBrowsing();
+      }
+    }
   }
 
   nsCOMPtr<nsIChannel> channel = aDoc->GetChannel();
   return channel && NS_UsePrivateBrowsing(channel);
 }
 
 // static
 bool
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -2106,23 +2106,20 @@ imgLoader::LoadImage(nsIURI* aURI,
   RefPtr<imgRequest> request;
 
   nsresult rv;
   nsLoadFlags requestFlags = nsIRequest::LOAD_NORMAL;
 
 #ifdef DEBUG
   bool isPrivate = false;
 
-  if (aLoadGroup) {
-    nsCOMPtr<nsIInterfaceRequestor> callbacks;
-    aLoadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks));
-    if (callbacks) {
-      nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(callbacks);
-      isPrivate = loadContext && loadContext->UsePrivateBrowsing();
-    }
+  if (aLoadingDocument) {
+    isPrivate = nsContentUtils::IsInPrivateBrowsing(aLoadingDocument);
+  } else if (aLoadGroup) {
+    isPrivate = nsContentUtils::IsInPrivateBrowsing(aLoadGroup);
   }
   MOZ_ASSERT(isPrivate == mRespectPrivacy);
 #endif
 
   // Get the default load flags from the loadgroup (if possible)...
   if (aLoadGroup) {
     aLoadGroup->GetLoadFlags(&requestFlags);
   }