Bug 1638389 - skip events that principals are not matched; r=timhuang
authorLiang-Heng Chen <xeonchen@gmail.com>
Thu, 04 Jun 2020 09:00:34 +0000
changeset 533867 e9ba31526222335ae6549998b6958f33a8fdb798
parent 533866 d0c45557821bf26012eef0f77cbcf5833c88ce55
child 533868 42f2bdd06a959c9d01a659be6664e4ea79939b3b
push id37479
push userapavel@mozilla.com
push dateThu, 04 Jun 2020 15:32:20 +0000
treeherdermozilla-central@0d21bdf3fc01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstimhuang
bugs1638389
milestone79.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 1638389 - skip events that principals are not matched; r=timhuang The [[ https://searchfox.org/mozilla-central/rev/559b25eb41c1cbffcb90a34e008b8288312fcd25/dom/base/nsGlobalWindowInner.cpp#5070-5071 | assertion ]] is called in a [[ https://searchfox.org/mozilla-central/rev/559b25eb41c1cbffcb90a34e008b8288312fcd25/dom/storage/StorageNotifierService.cpp#86-87 | runnable ]], the condition was previously bailed out by the same [[ https://searchfox.org/mozilla-central/rev/559b25eb41c1cbffcb90a34e008b8288312fcd25/dom/storage/StorageNotifierService.cpp#78-81 | expression ]]. Dynamic FPI may potentially relaxed the effective storage principal from intrinsic storage principal to node principal, when it happened during the asynchrnous event, it will end up raise the assertion. Differential Revision: https://phabricator.services.mozilla.com/D78017
dom/storage/StorageNotifierService.cpp
--- a/dom/storage/StorageNotifierService.cpp
+++ b/dom/storage/StorageNotifierService.cpp
@@ -77,17 +77,27 @@ void StorageNotifierService::Broadcast(S
     // the window's one.
     if (!StorageUtils::PrincipalsEqual(
             aEvent->GetPrincipal(), observer->GetEffectiveStoragePrincipal())) {
       continue;
     }
 
     RefPtr<Runnable> r = NS_NewRunnableFunction(
         "StorageNotifierService::Broadcast",
-        [observer, event, aStorageType, aPrivateBrowsing]() {
+        [observer, event, aStorageType, aPrivateBrowsing,
+         aImmediateDispatch]() {
+          // Check principals again. EffectiveStoragePrincipal may be changed
+          // when relaxed.
+          if (!aImmediateDispatch &&
+              !StorageUtils::PrincipalsEqual(
+                  event->GetPrincipal(),
+                  observer->GetEffectiveStoragePrincipal())) {
+            return;
+          }
+
           observer->ObserveStorageNotification(event, aStorageType,
                                                aPrivateBrowsing);
         });
 
     if (aImmediateDispatch) {
       r->Run();
     } else {
       nsCOMPtr<nsIEventTarget> et = observer->GetEventTarget();