From f4d523ab1afb324afff1284027d702929f50b3ef Mon Sep 17 00:00:00 2001 From: Mike Connor Date: Fri, 27 Feb 2009 23:55:04 +0330 Subject: [PATCH] Bug 479461 - Private browsing, close window, can't restore session; r=gavin a1.9.1=blocking-firefox3.1+ --- .../src/nsPrivateBrowsingService.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js b/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js index c68b4e2b07bb..c0b8278114f1 100644 --- a/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js +++ b/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js @@ -171,11 +171,17 @@ PrivateBrowsingService.prototype = { let browser = Cc["@mozilla.org/appshell/window-mediator;1"]. getService(Ci.nsIWindowMediator). - getMostRecentWindow("navigator:browser").gBrowser; - // this ensures a clean slate from which to transition into or out of - // private browsing - browser.addTab(); - browser.removeTab(browser.tabContainer.firstChild); + getMostRecentWindow("navigator:browser"); + + // if all browser windows are closed (i.e. on Mac) we won't have a window here + // this is only needed on Mac, but it's just good hygiene + if (browser) { + // this ensures a clean slate from which to transition into or out of + // private browsing + browser = browser.gBrowser; + browser.addTab(); + browser.removeTab(browser.tabContainer.firstChild); + } } } else