Bug 1384908 - nsGlobalWindow::ObserveStorageNotification should check if the private browsing state has changed, r=asuth
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 28 Jul 2017 08:58:09 +0200
changeset 420309 795aeb51da2b9b2b3667b58ca02e477657253478
parent 420308 dc186bad8bd537919a15722a1a79dd46660f95f1
child 420310 a57d8f30d1bf5de3ba5201a6f5e2a08ef1cf7d85
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1384908
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 1384908 - nsGlobalWindow::ObserveStorageNotification should check if the private browsing state has changed, r=asuth
dom/base/nsGlobalWindow.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -12384,17 +12384,22 @@ nsGlobalWindow::Observe(nsISupports* aSu
 
 void
 nsGlobalWindow::ObserveStorageNotification(StorageEvent* aEvent,
                                            const char16_t* aStorageType,
                                            bool aPrivateBrowsing)
 {
   MOZ_ASSERT(aEvent);
 
-  MOZ_DIAGNOSTIC_ASSERT(IsPrivateBrowsing() == aPrivateBrowsing);
+  // The private browsing check must be done here again because this window
+  // could have changed its state before the notification check and now. This
+  // happens in case this window did have a docShell at that time.
+  if (aPrivateBrowsing != IsPrivateBrowsing()) {
+    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;
   }