From 56064db6ce8e22ce2ceca81b4f9833f8bd604a08 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 12 Feb 2016 21:29:49 -0500 Subject: [PATCH] Bug 1247872. Just get our private browsing state directly off the docshells we already have instead of trying to indirect through their documents. r=smaug --- docshell/base/nsDocShell.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index b90661b2640..3df3473a3ca 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -3492,22 +3492,19 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem, nsCOMPtr targetDS = do_QueryInterface(aTargetItem); nsCOMPtr accessingDS = do_QueryInterface(aAccessingItem); - if (!!targetDS != !!accessingDS) { - // We must be able to convert both or neither to nsIDocShell. + if (!targetDS || !accessingDS) { + // We must be able to convert both to nsIDocShell. return false; } - if (targetDS && accessingDS && - (targetDS->GetIsInBrowserElement() != - accessingDS->GetIsInBrowserElement() || - targetDS->GetAppId() != accessingDS->GetAppId())) { + if (targetDS->GetIsInBrowserElement() != accessingDS->GetIsInBrowserElement() || + targetDS->GetAppId() != accessingDS->GetAppId()) { return false; } // A private document can't access a non-private one, and vice versa. - if (aTargetItem->GetDocument()->GetLoadContext()->UsePrivateBrowsing() != - aAccessingItem->GetDocument()->GetLoadContext()->UsePrivateBrowsing()) - { + if (static_cast(targetDS.get())->UsePrivateBrowsing() != + static_cast(accessingDS.get())->UsePrivateBrowsing()) { return false; }