Backout changeset d927bdcfd2e4 (bug 795015) because of test failures
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 28 Sep 2012 16:55:22 -0400
changeset 108651 9d1eb0a8b5cd3500bb34db5a6457835ce68d26cd
parent 108650 6c68ef18d3400d2dc49b973845e62bac7c1ed90f
child 108652 5fbf17bdec328ce842c0fdcb8e327b3324a411a6
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
bugs795015
milestone18.0a1
backs outd927bdcfd2e458d1f23479fa86fa5a0a12d95edb
Backout changeset d927bdcfd2e4 (bug 795015) because of test failures
browser/components/privatebrowsing/src/nsPrivateBrowsingService.js
--- a/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js
+++ b/browser/components/privatebrowsing/src/nsPrivateBrowsingService.js
@@ -56,17 +56,17 @@ const STATE_RESTORE_FINISHED = 3;
 function PrivateBrowsingService() {
   this._obs = Cc["@mozilla.org/observer-service;1"].
               getService(Ci.nsIObserverService);
   this._obs.addObserver(this, "profile-after-change", true);
   this._obs.addObserver(this, "quit-application-granted", true);
   this._obs.addObserver(this, "private-browsing", true);
   this._obs.addObserver(this, "command-line-startup", true);
   this._obs.addObserver(this, "sessionstore-browser-state-restored", true);
-  this._obs.addObserver(this, "chrome-document-global-created", true);
+  this._obs.addObserver(this, "domwindowopened", true);
 
   // List of nsIXULWindows we are going to be closing during the transition
   this._windowsToClose = [];
 }
 
 PrivateBrowsingService.prototype = {
   // Preferences Service
   get _prefs() {
@@ -492,35 +492,27 @@ PrivateBrowsingService.prototype = {
         }
         break;
       case "sessionstore-browser-state-restored":
         if (this._currentStatus == STATE_WAITING_FOR_RESTORE) {
           this._currentStatus = STATE_RESTORE_FINISHED;
           this._notifyIfTransitionComplete();
         }
         break;
-      case "chrome-document-global-created":
+      case "domwindowopened":
         let aWindow = aSubject;
-        let doc = aWindow.document;
-        let onLoad = function PBS__onWindowLoad(aEvent) {
-          if (aEvent) { // If being called from an event handler, aEvent will be non-null
-            aWindow.removeEventListener("load", onLoad);
+        let self = this;
+        aWindow.addEventListener("load", function PBS__onWindowLoad(aEvent) {
+          aWindow.removeEventListener("load", arguments.callee);
+          if (aWindow.document
+                     .documentElement
+                     .getAttribute("windowtype") == "navigator:browser") {
+            self._setPerWindowPBFlag(aWindow, self._inPrivateBrowsing);
           }
-          if (doc.documentElement
-                 .getAttribute("windowtype") == "navigator:browser") {
-            this._setPerWindowPBFlag(aWindow, this._inPrivateBrowsing);
-          }
-        }.bind(this);
-        // Make sure to catch any possible cases where the window's load event
-        // has already been fired by the time that we get here.
-        if (doc.readyState == "complete") {
-          onLoad(null);
-        } else {
-          aWindow.addEventListener("load", onLoad, false);
-        }
+        }, false);
         break;
     }
   },
 
   // nsICommandLineHandler
 
   handle: function PBS_handle(aCmdLine) {
     if (aCmdLine.handleFlag("private", false))