Backed out changeset 4fea98061fae because of the orange
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 18 Nov 2010 18:34:03 -0500
changeset 57878 7c2555c35ad2b70e9a700ea2002ee1fc9d969358
parent 57876 c29356cef6d4164447ab9a2352badc8ade1e42a7
child 57879 5a04cd531f5197078e165981b4254e9fd4d59506
push id17057
push usereakhgari@mozilla.com
push dateThu, 18 Nov 2010 23:36:40 +0000
treeherdermozilla-central@5a04cd531f51 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0b8pre
backs out4fea98061faea1cdb1749cd0511dc123945410d8
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 4fea98061fae because of the orange
browser/base/content/browser.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_fastswitch.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -7479,18 +7479,21 @@ let gPrivateBrowsingUI = {
     if (aTopic == "private-browsing") {
       if (aData == "enter")
         this.onEnterPrivateBrowsing();
       else if (aData == "exit")
         this.onExitPrivateBrowsing();
     }
     else if (aTopic == "private-browsing-transition-complete") {
       if (this._disableUIOnToggle) {
-        document.getElementById("Tools:PrivateBrowsing")
-                .removeAttribute("disabled");
+        // use setTimeout here in order to make the code testable
+        setTimeout(function() {
+          document.getElementById("Tools:PrivateBrowsing")
+                  .removeAttribute("disabled");
+        }, 0);
       }
     }
   },
 
   _shouldEnter: function PBUI__shouldEnter() {
     try {
       // Never prompt if the session is not going to be closed, or if user has
       // already requested not to be prompted.
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_fastswitch.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_fastswitch.js
@@ -43,50 +43,42 @@ function test() {
   let pb = Cc["@mozilla.org/privatebrowsing;1"].
            getService(Ci.nsIPrivateBrowsingService);
   let pbCmd = document.getElementById("Tools:PrivateBrowsing");
   waitForExplicitFinish();
 
   let pass = 1;
   function observer(aSubject, aTopic, aData) {
     switch (aTopic) {
+      case "private-browsing":
+        setTimeout(function () {
+          ok(document.getElementById("Tools:PrivateBrowsing").hasAttribute("disabled"),
+             "The private browsing command should be disabled immediately after the mode switch");
+        }, 0);
+        break;
+
       case "private-browsing-transition-complete":
         if (pass++ == 1) {
           setTimeout(function () {
             ok(!pbCmd.hasAttribute("disabled"),
                "The private browsing command should be re-enabled after entering the private browsing mode");
 
             pb.privateBrowsingEnabled = false;
           }, 100);
         }
         else {
           setTimeout(function () {
             ok(!pbCmd.hasAttribute("disabled"),
                "The private browsing command should be re-enabled after exiting the private browsing mode");
 
+            Services.obs.removeObserver(observer, "private-browsing");
+            Services.obs.removeObserver(observer, "private-browsing-transition-complete");
             finish();
           }, 100);
         }
         break;
     }
-    Services.obs.removeObserver(observer, "private-browsing-transition-complete");
   }
-  let originalOnEnter = gPrivateBrowsingUI.onEnterPrivateBrowsing;
-  gPrivateBrowsingUI.onEnterPrivateBrowsing = function() {
-    originalOnEnter.apply(gPrivateBrowsingUI, arguments);
-    ok(pbCmd.hasAttribute("disabled"),
-       "The private browsing command should be disabled right after entering the private browsing mode");
-    Services.obs.addObserver(observer, "private-browsing-transition-complete", false);
-  };
-  let originalOnExit = gPrivateBrowsingUI.onExitPrivateBrowsing;
-  gPrivateBrowsingUI.onExitPrivateBrowsing = function() {
-    originalOnExit.apply(gPrivateBrowsingUI, arguments);
-    ok(pbCmd.hasAttribute("disabled"),
-       "The private browsing command should be disabled right after exiting the private browsing mode");
-    Services.obs.addObserver(observer, "private-browsing-transition-complete", false);
-  };
-  registerCleanupFunction(function() {
-    gPrivateBrowsingUI.onEnterPrivateBrowsing = originalOnEnter;
-    gPrivateBrowsingUI.onExitPrivateBrowsing = originalOnExit;
-  });
+  Services.obs.addObserver(observer, "private-browsing", false);
+  Services.obs.addObserver(observer, "private-browsing-transition-complete", false);
 
   pb.privateBrowsingEnabled = true;
 }