Bug 801237 - Make browser_privatebrowsing_viewsource.js use "private-browsing-transition-complete" instead of using a progress listener; r=jdm
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 12 Oct 2012 11:25:47 -0400
changeset 110459 40204318c5b71f00cd183e540d1e009b6cfcbeeb
parent 110458 3ff5410852cc65d582e1ae4eed6e18c6a2f36fcc
child 110460 ca741411bd170132ac2cb3c6f4b803918132003d
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersjdm
bugs801237
milestone19.0a1
Bug 801237 - Make browser_privatebrowsing_viewsource.js use "private-browsing-transition-complete" instead of using a progress listener; r=jdm
browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_viewsource.js
--- a/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_viewsource.js
+++ b/browser/components/privatebrowsing/test/browser/obsolete/browser_privatebrowsing_viewsource.js
@@ -47,32 +47,25 @@ function test() {
 
     function step1() {
       function observer(aSubject, aTopic, aData) {
         if (aTopic == "domwindowclosed") {
           ok(true, "Entering the private browsing mode should close the view source window");
           Services.ww.unregisterNotification(observer);
 
           step2();
+        } else if (aTopic == "domwindowopened") {
+          ok(false, "Entering the private browsing mode should not open any view source window");
+        } else if (aTopic == "private-browsing-transition-complete") {
+          Services.obs.removeObserver(observer, "private-browsing-transition-complete");
+          step3();
         }
-        else if (aTopic == "domwindowopened")
-          ok(false, "Entering the private browsing mode should not open any view source window");
       }
       Services.ww.registerNotification(observer);
-
-      gBrowser.addTabsProgressListener({
-        onStateChange: function(aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
-          if (aStateFlags & (Ci.nsIWebProgressListener.STATE_STOP |
-                             Ci.nsIWebProgressListener.STATE_IS_WINDOW)) {
-            gBrowser.removeTabsProgressListener(this);
-
-            step3();
-          }
-        }
-      });
+      Services.obs.addObserver(observer, "private-browsing-transition-complete", false);
 
       // enter private browsing mode
       pb.privateBrowsingEnabled = true;
     }
 
     let events = 0, step2, step3;
     step2 = step3 = function() {
       if (++events == 2)