Bug 1383299 - Fix xpcshell test failures, r=dao
Some xpcshell tests run with _windowless_ browser and calls its LoadURI().
It then failed to get `aBrowser.contentWindow` when we tried to create OA
and detected if the browser was in the private mode.
MozReview-Commit-ID: DWGMyfao1wG
--- a/toolkit/modules/PrivateBrowsingUtils.jsm
+++ b/toolkit/modules/PrivateBrowsingUtils.jsm
@@ -30,21 +30,22 @@ this.PrivateBrowsingUtils = {
// This should be used only in frame scripts.
isContentWindowPrivate: function pbu_isWindowPrivate(aWindow) {
return this.privacyContextFromWindow(aWindow).usePrivateBrowsing;
},
isBrowserPrivate(aBrowser) {
let chromeWin = aBrowser.ownerGlobal;
- if (chromeWin.gMultiProcessBrowser || !aBrowser.isConnected) {
+ if (chromeWin.gMultiProcessBrowser || !aBrowser.contentWindow) {
// In e10s we have to look at the chrome window's private
// browsing status since the only alternative is to check the
// content window, which is in another process. If the browser
- // is lazy then the content window doesn't exist.
+ // is lazy or is running in windowless configuration then the
+ // content window doesn't exist.
return this.isWindowPrivate(chromeWin);
}
return this.privacyContextFromWindow(aBrowser.contentWindow).usePrivateBrowsing;
},
privacyContextFromWindow: function pbu_privacyContextFromWindow(aWindow) {
return aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)