Bug 1383299 - Fix xpcshell test failures, r=dao draft
authorEvelyn Hung <jj.evelyn@gmail.com>
Tue, 22 Aug 2017 12:04:19 +0800
changeset 651163 cb77298910560a568cc03887f3739f235a4ad20d
parent 650264 0a7870ce989b679f8aa6a4f6eb5e2b25d6289044
child 727605 ef24c3067ed5e2047ae33c7d1881c29e2aca0eb9
push id75615
push userbmo:ehung@mozilla.com
push dateWed, 23 Aug 2017 09:22:11 +0000
reviewersdao
bugs1383299
milestone57.0a1
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
toolkit/modules/PrivateBrowsingUtils.jsm
--- 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)