Bug 1483604 - Part 1: Only call NotifyContentBlockingState() when the channel argument is non-null; r=smaug
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 15 Aug 2018 17:55:37 -0400
changeset 431835 05a3c486ad1e5472cb22c0184adc26beecc39cb0
parent 431834 52844031165ab767dfd5533740a22355640dab6d
child 431836 be2d0537375471a1a5d0607821d06805a3c4ae8b
push id34451
push userebalazs@mozilla.com
push dateThu, 16 Aug 2018 09:25:15 +0000
treeherdermozilla-central@161817e6d127 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1483604
milestone63.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 1483604 - Part 1: Only call NotifyContentBlockingState() when the channel argument is non-null; r=smaug
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -8911,17 +8911,17 @@ nsContentUtils::StorageDisabledByAntiTra
     } else if (aChannel) {
       nsCOMPtr<mozIDOMWindowProxy> win;
       nsresult rv = thirdPartyUtil->GetTopWindowForChannel(aChannel,
                                                            getter_AddRefs(win));
       NS_ENSURE_SUCCESS(rv, false);
       pwin = nsPIDOMWindowOuter::From(win);
     }
 
-    if (pwin) {
+    if (pwin && aChannel) {
       pwin->NotifyContentBlockingState(
         nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES, aChannel);
     }
   }
   return disabled;
 }
 
 // static, private
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -2949,16 +2949,18 @@ public:
    * (if that is possible, the caller should use StorageAllowedForWindow)
    */
   static StorageAccess StorageAllowedForPrincipal(nsIPrincipal* aPrincipal);
 
   /*
    * Returns true if this window/channel/aPrincipal should disable storages
    * because of the anti-tracking feature.
    * Note that either aWindow or aChannel may be null when calling this function.
+   * If the caller wants the UI to be notified when the storage gets disabled,
+   * it must pass a non-null channel object.
    */
   static bool StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
                                             nsIChannel* aChannel,
                                             nsIPrincipal* aPrincipal,
                                             nsIURI* aURI);
 
   /*
    * Returns true if this window/channel is a 3rd party context.