Backed out changeset 960a0dc9092f (bug 1379568) for frequently timing out web-platform-test /webstorage/storage_setitem.html. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Wed, 12 Jul 2017 19:04:44 +0200
changeset 607713 da31f44d2f8a27bfe0d97905346dcf891a5c170f
parent 607712 999aa7b6683d7f0cf481f8dd0e8a9ba3dade4a05
child 607714 28f351ecb49b91cba62b4be6ed222657a4b01143
push id68095
push userbmo:rbarker@mozilla.com
push dateWed, 12 Jul 2017 20:01:47 +0000
reviewersbackout
bugs1379568
milestone56.0a1
backs out960a0dc9092fdba8ef5a367a42ddb3f9a3ec3398
Backed out changeset 960a0dc9092f (bug 1379568) for frequently timing out web-platform-test /webstorage/storage_setitem.html. r=backout
dom/base/nsGlobalWindow.cpp
dom/storage/StorageNotifierService.cpp
dom/storage/StorageNotifierService.h
dom/storage/moz.build
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -19,17 +19,16 @@
 #include "nsIDOMStorageManager.h"
 #include "mozilla/dom/LocalStorage.h"
 #include "mozilla/dom/Storage.h"
 #include "mozilla/dom/IdleRequest.h"
 #include "mozilla/dom/Performance.h"
 #include "mozilla/dom/StorageEvent.h"
 #include "mozilla/dom/StorageEventBinding.h"
 #include "mozilla/dom/StorageNotifierService.h"
-#include "mozilla/dom/StorageUtils.h"
 #include "mozilla/dom/Timeout.h"
 #include "mozilla/dom/TimeoutHandler.h"
 #include "mozilla/dom/TimeoutManager.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
 #include "mozilla/dom/WindowOrientationObserver.h"
 #endif
 #include "nsDOMOfflineResourceList.h"
@@ -494,29 +493,17 @@ public:
                              bool aPrivateBrowsing) override
   {
     if (mWindow) {
       mWindow->ObserveStorageNotification(aEvent, aStorageType,
                                           aPrivateBrowsing);
     }
   }
 
-  nsIPrincipal*
-  GetPrincipal() const override
-  {
-    return mWindow ? mWindow->GetPrincipal() : nullptr;
-  }
-
-  bool
-  IsPrivateBrowsing() const override
-  {
-    return mWindow ? mWindow->IsPrivateBrowsing() : false;
-  }
-
-  nsIEventTarget*
+  virtual nsIEventTarget*
   GetEventTarget() const override
   {
     return mWindow ? mWindow->EventTargetFor(TaskCategory::Other) : nullptr;
   }
 
 private:
   ~nsGlobalWindowObserver() = default;
 
@@ -12377,17 +12364,26 @@ nsGlobalWindow::Observe(nsISupports* aSu
 
 void
 nsGlobalWindow::ObserveStorageNotification(StorageEvent* aEvent,
                                            const char16_t* aStorageType,
                                            bool aPrivateBrowsing)
 {
   MOZ_ASSERT(aEvent);
 
-  MOZ_DIAGNOSTIC_ASSERT(IsPrivateBrowsing() == aPrivateBrowsing);
+  // Enforce that the source storage area's private browsing state matches
+  // this window's state.  These flag checks and their maintenance independent
+  // from the principal's OriginAttributes matter because chrome docshells
+  // that are part of private browsing windows can be private browsing without
+  // having their OriginAttributes set (because they have the system
+  // principal).
+  bool isPrivateBrowsing = IsPrivateBrowsing();
+  if (isPrivateBrowsing != aPrivateBrowsing) {
+    return;
+  }
 
   // LocalStorage can only exist on an inner window, and we don't want to
   // generate events on frozen or otherwise-navigated-away from windows.
   // (Actually, this code used to try and buffer events for frozen windows,
   // but it never worked, so we've removed it.  See bug 1285898.)
   if (!IsInnerWindow() || !AsInner()->IsCurrentInnerWindow() || IsFrozen()) {
     return;
   }
@@ -12429,19 +12425,28 @@ nsGlobalWindow::ObserveStorageNotificati
     fireMozStorageChanged = mSessionStorage == changingStorage;
     if (fireMozStorageChanged) {
       eventType.AssignLiteral("MozSessionStorageChanged");
     }
   }
 
   else {
     MOZ_ASSERT(!NS_strcmp(aStorageType, u"localStorage"));
-
-    MOZ_DIAGNOSTIC_ASSERT(StorageUtils::PrincipalsEqual(aEvent->GetPrincipal(),
-                                                        principal));
+    nsIPrincipal* storagePrincipal = aEvent->GetPrincipal();
+    if (!storagePrincipal) {
+      return;
+    }
+
+    bool equals = false;
+    nsresult rv = storagePrincipal->Equals(principal, &equals);
+    NS_ENSURE_SUCCESS_VOID(rv);
+
+    if (!equals) {
+      return;
+    }
 
     fireMozStorageChanged = mLocalStorage == aEvent->GetStorageArea();
 
     if (fireMozStorageChanged) {
       eventType.AssignLiteral("MozLocalStorageChanged");
     }
   }
 
--- a/dom/storage/StorageNotifierService.cpp
+++ b/dom/storage/StorageNotifierService.cpp
@@ -62,38 +62,20 @@ StorageNotifierService::Broadcast(Storag
   RefPtr<StorageEvent> event = aEvent;
 
   nsTObserverArray<RefPtr<StorageNotificationObserver>>::ForwardIterator
     iter(service->mObservers);
 
   while (iter.HasMore()) {
     RefPtr<StorageNotificationObserver> observer = iter.GetNext();
 
-    // Enforce that the source storage area's private browsing state matches
-    // this window's state.  These flag checks and their maintenance independent
-    // from the principal's OriginAttributes matter because chrome docshells
-    // that are part of private browsing windows can be private browsing without
-    // having their OriginAttributes set (because they have the system
-    // principal).
-    if (aPrivateBrowsing != observer->IsPrivateBrowsing()) {
-      continue;
-    }
-
-    // No reasons to continue if the principal of the event doesn't match with
-    // the window's one.
-    if (!StorageUtils::PrincipalsEqual(aEvent->GetPrincipal(),
-                                       observer->GetPrincipal())) {
-      continue;
-    }
-
     RefPtr<Runnable> r = NS_NewRunnableFunction(
       "StorageNotifierService::Broadcast",
       [observer, event, aStorageType, aPrivateBrowsing] () {
-        observer->ObserveStorageNotification(event, aStorageType,
-                                             aPrivateBrowsing);
+        observer->ObserveStorageNotification(event, aStorageType, aPrivateBrowsing);
       });
 
     if (aImmediateDispatch) {
       r->Run();
     } else {
       nsCOMPtr<nsIEventTarget> et = observer->GetEventTarget();
       if (et) {
         et->Dispatch(r.forget());
--- a/dom/storage/StorageNotifierService.h
+++ b/dom/storage/StorageNotifierService.h
@@ -19,22 +19,16 @@ class StorageNotificationObserver
 public:
   NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
 
   virtual void
   ObserveStorageNotification(StorageEvent* aEvent,
                              const char16_t* aStorageType,
                              bool aPrivateBrowsing) = 0;
 
-  virtual bool
-  IsPrivateBrowsing() const = 0;
-
-  virtual nsIPrincipal*
-  GetPrincipal() const = 0;
-
   virtual nsIEventTarget*
   GetEventTarget() const = 0;
 };
 
 class StorageNotifierService final
 {
 public:
   NS_INLINE_DECL_REFCOUNTING(StorageNotifierService)
--- a/dom/storage/moz.build
+++ b/dom/storage/moz.build
@@ -9,17 +9,16 @@ with Files("**"):
 
 EXPORTS.mozilla.dom += [
     'LocalStorage.h',
     'LocalStorageManager.h',
     'SessionStorageManager.h',
     'Storage.h',
     'StorageIPC.h',
     'StorageNotifierService.h',
-    'StorageUtils.h',
 ]
 
 UNIFIED_SOURCES += [
     'LocalStorage.cpp',
     'LocalStorageCache.cpp',
     'LocalStorageManager.cpp',
     'SessionStorage.cpp',
     'SessionStorageCache.cpp',