diff --git a/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js b/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js index 4a3086727e25..e7cd108d0b4b 100644 --- a/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js +++ b/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js @@ -101,12 +101,19 @@ PrivateBrowsingService.prototype = { .usePrivateBrowsing = aFlag; }, - _onBeforePrivateBrowsingModeChange: function PBS__onBeforePrivateBrowsingModeChange() { + _adjustPBFlagOnExistingWindows: function PBS__adjustPBFlagOnExistingWindows() { var windowsEnum = Services.wm.getEnumerator(null); while (windowsEnum.hasMoreElements()) { var window = windowsEnum.getNext(); this._setPerWindowPBFlag(window, this._inPrivateBrowsing); } + }, + + _onBeforePrivateBrowsingModeChange: function PBS__onBeforePrivateBrowsingModeChange() { + // If we're about to enter PB mode, adjust the flags now + if (this._inPrivateBrowsing) { + this._adjustPBFlagOnExistingWindows(); + } // nothing needs to be done here if we're enabling at startup if (!this._autoStarted) { @@ -180,6 +187,11 @@ PrivateBrowsingService.prototype = { } else this._saveSession = false; + + // If we're about to leave PB mode, adjust the flags now + if (!this._inPrivateBrowsing) { + this._adjustPBFlagOnExistingWindows(); + } }, _onAfterPrivateBrowsingModeChange: function PBS__onAfterPrivateBrowsingModeChange() { diff --git a/toolkit/components/places/AsyncFaviconHelpers.cpp b/toolkit/components/places/AsyncFaviconHelpers.cpp index 3e82dd272dc2..01ca6933fba0 100644 --- a/toolkit/components/places/AsyncFaviconHelpers.cpp +++ b/toolkit/components/places/AsyncFaviconHelpers.cpp @@ -515,7 +515,18 @@ AsyncFetchAndSetIconForPage::AsyncFetchAndSetIconForPage( if (pbService) { bool inPrivateBrowsing = false; if (NS_SUCCEEDED(pbService->GetPrivateBrowsingEnabled(&inPrivateBrowsing))) { - MOZ_ASSERT(inPrivateBrowsing == mFaviconLoadPrivate); + // In one specific case that we know of, it is possible for these flags + // to not match (bug 801151). We mostly care about the cases where the + // global private browsing mode is on, but the favicon load is not marked + // as private, as those cases will cause privacy leaks. But because + // fixing bug 801151 properly is going to mean tons of really dirty and + // fragile work which might cause other types of problems, we fatally + // assert the condition which would be a privacy leak, and non-fatally + // assert the other side of the condition which would designate a bug, + // but not a privacy sensitive one. + MOZ_ASSERT_IF(inPrivateBrowsing && !mFaviconLoadPrivate, false); + NS_ASSERTION(inPrivateBrowsing == mFaviconLoadPrivate, + "The favicon load flag and the global PB flag do not match"); } } #endif