Bug 806702 - Port browser_privatebrowsing_zoom.js to the new per-window PB APIs; r=ehsan
authorBellindira Castillo [:bellindira] <bellindira@appcoast.com>
Wed, 21 Nov 2012 21:04:49 -0600
changeset 114048 45162db9a860c4c6d7a6b4a78815ecbaf1417f72
parent 114047 25ab5381a8e0122f125facfa66560f0cab15690d
child 114049 a2858a64fe77536590e4b5b943b226ff5fc5e7db
push id18517
push usereakhgari@mozilla.com
push dateThu, 22 Nov 2012 23:39:10 +0000
treeherdermozilla-inbound@45162db9a860 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs806702
milestone20.0a1
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
Bug 806702 - Port browser_privatebrowsing_zoom.js to the new per-window PB APIs; r=ehsan
browser/components/privatebrowsing/test/browser/perwindow/Makefile.in
browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_zoom.js
--- a/browser/components/privatebrowsing/test/browser/perwindow/Makefile.in
+++ b/browser/components/privatebrowsing/test/browser/perwindow/Makefile.in
@@ -37,14 +37,15 @@ MOCHITEST_BROWSER_FILES =  \
 		browser_privatebrowsing_popupblocker.js \
 		browser_privatebrowsing_protocolhandler.js \
 		browser_privatebrowsing_protocolhandler_page.html \
 		browser_privatebrowsing_theming.js \
 		browser_privatebrowsing_ui.js \
 		browser_privatebrowsing_urlbarfocus.js \
 		browser_privatebrowsing_windowtitle.js \
 		browser_privatebrowsing_windowtitle_page.html \
+		browser_privatebrowsing_zoom.js \
 		browser_privatebrowsing_zoomrestore.js \
 		popup.html \
 		title.sjs \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
copy from browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoom.js
copy to browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_zoom.js
--- a/browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_zoom.js
+++ b/browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_zoom.js
@@ -1,62 +1,59 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // This test makes sure that private browsing turns off doesn't cause zoom
 // settings to be reset on tab switch (bug 464962)
 
 function test() {
-  // initialization
-  gPrefService.setBoolPref("browser.privatebrowsing.keep_current_session", true);
-  let pb = Cc["@mozilla.org/privatebrowsing;1"].
-           getService(Ci.nsIPrivateBrowsingService);
-
-  // enter private browsing mode
-  pb.privateBrowsingEnabled = true;
-
-  let tabAbout = gBrowser.addTab();
-  gBrowser.selectedTab = tabAbout;
-
   waitForExplicitFinish();
 
-  let aboutBrowser = gBrowser.getBrowserForTab(tabAbout);
-  aboutBrowser.addEventListener("load", function onAboutBrowserLoad() {
-    aboutBrowser.removeEventListener("load", onAboutBrowserLoad, true);
-    let tabMozilla = gBrowser.addTab();
-    gBrowser.selectedTab = tabMozilla;
+  function testZoom(aWindow, aCallback) {
+    executeSoon(function() {
+      let tabAbout = aWindow.gBrowser.addTab();
+      aWindow.gBrowser.selectedTab = tabAbout;
+
+      let aboutBrowser = aWindow.gBrowser.getBrowserForTab(tabAbout);
+      aboutBrowser.addEventListener("load", function onAboutBrowserLoad() {
+        aboutBrowser.removeEventListener("load", onAboutBrowserLoad, true);
+        let tabMozilla = aWindow.gBrowser.addTab();
+        aWindow.gBrowser.selectedTab = tabMozilla;
 
-    let mozillaBrowser = gBrowser.getBrowserForTab(tabMozilla);
-    mozillaBrowser.addEventListener("load", function onMozillaBrowserLoad() {
-      mozillaBrowser.removeEventListener("load", onMozillaBrowserLoad, true);
-      let mozillaZoom = ZoomManager.zoom;
+        let mozillaBrowser = aWindow.gBrowser.getBrowserForTab(tabMozilla);
+        mozillaBrowser.addEventListener("load", function onMozillaBrowserLoad() {
+          mozillaBrowser.removeEventListener("load", onMozillaBrowserLoad, true);
+          let mozillaZoom = aWindow.ZoomManager.zoom;
 
-      // change the zoom on the mozilla page
-      FullZoom.enlarge();
-      // make sure the zoom level has been changed
-      isnot(ZoomManager.zoom, mozillaZoom, "Zoom level can be changed");
-      mozillaZoom = ZoomManager.zoom;
+          // change the zoom on the mozilla page
+          aWindow.FullZoom.enlarge();
+          // make sure the zoom level has been changed
+          isnot(aWindow.ZoomManager.zoom, mozillaZoom, "Zoom level can be changed");
+          mozillaZoom = aWindow.ZoomManager.zoom;
 
-      // switch to about: tab
-      gBrowser.selectedTab = tabAbout;
+          // switch to about: tab
+          aWindow.gBrowser.selectedTab = tabAbout;
 
-      // switch back to mozilla tab
-      gBrowser.selectedTab = tabMozilla;
+          // switch back to mozilla tab
+          aWindow.gBrowser.selectedTab = tabMozilla;
 
-      // make sure the zoom level has not changed
-      is(ZoomManager.zoom, mozillaZoom,
-        "Entering private browsing should not reset the zoom on a tab");
-
-      // leave private browsing mode
-      pb.privateBrowsingEnabled = false;
+          // make sure the zoom level has not changed
+          is(aWindow.ZoomManager.zoom, mozillaZoom,
+            "Entering private browsing should not reset the zoom on a tab");
 
-      // cleanup
-      gPrefService.clearUserPref("browser.privatebrowsing.keep_current_session");
-      FullZoom.reset();
-      gBrowser.removeTab(tabMozilla);
-      gBrowser.removeTab(tabAbout);
-      finish();
-    }, true);
-    mozillaBrowser.contentWindow.location = "about:mozilla";
-  }, true);
-  aboutBrowser.contentWindow.location = "about:";
+          // cleanup
+          aWindow.FullZoom.reset();
+          aWindow.gBrowser.removeTab(tabMozilla);
+          aWindow.gBrowser.removeTab(tabAbout);
+          aWindow.close();
+          aCallback();
+        }, true);
+        mozillaBrowser.contentWindow.location = "about:mozilla";
+      }, true);
+      aboutBrowser.contentWindow.location = "about:";
+    });
+  }
+
+  whenNewWindowLoaded({private: true}, function(privateWindow) {
+    testZoom(privateWindow, finish);
+  });
 }