Bug 806717 - Port browser_tabview_bug650280.js to the new per-tab PB APIs; r=ehsan
authorBellindira Castillo [:bellindira] <bellindira@appcoast.com>
Wed, 05 Dec 2012 11:53:55 -0600
changeset 115047 b227c83d5914fcfd72e865f9d42bac507ca343b1
parent 115046 c93e85a125db734a60d8018a4e5d92fdd2071d0c
child 115048 bf0f66f0ab9dac0c1ee27c5f618070f009da6b3e
push id23959
push usereakhgari@mozilla.com
push dateWed, 05 Dec 2012 19:31:00 +0000
treeherdermozilla-central@b227c83d5914 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs806717, 650280
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 806717 - Port browser_tabview_bug650280.js to the new per-tab PB APIs; r=ehsan DONTBUILD because this is NPOTB for global PB builds
browser/components/tabview/test/Makefile.in
browser/components/tabview/test/browser_tabview_bug650280_perwindowpb.js
--- a/browser/components/tabview/test/Makefile.in
+++ b/browser/components/tabview/test/Makefile.in
@@ -101,17 +101,16 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug641802.js \
                  browser_tabview_bug642793.js \
                  browser_tabview_bug643392.js \
                  browser_tabview_bug644097.js \
                  browser_tabview_bug648882.js \
                  browser_tabview_bug649006.js \
                  browser_tabview_bug649307.js \
                  browser_tabview_bug649319.js \
-                 browser_tabview_bug650280.js \
                  browser_tabview_bug650573.js \
                  browser_tabview_bug651311.js \
                  browser_tabview_bug654295.js \
                  browser_tabview_bug654721.js \
                  browser_tabview_bug654941.js \
                  browser_tabview_bug655269.js \
                  browser_tabview_bug656778.js \
                  browser_tabview_bug656913.js \
@@ -164,21 +163,23 @@ include $(topsrcdir)/config/rules.mk
                  test_bug678374.html \
                  test_bug678374_icon16.png \
                  $(NULL)
 
 ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
 _BROWSER_FILES += \
                  browser_tabview_bug624265_perwindowpb.js \
                  browser_tabview_bug624727_perwindowpb.js \
+                 browser_tabview_bug650280_perwindowpb.js \
                  $(NULL)
 else
 _BROWSER_FILES += \
                  browser_tabview_bug624265.js \
                  browser_tabview_bug624727.js \
+                 browser_tabview_bug650280.js \
                  $(NULL)
 endif
 
 
 # browser_tabview_bug597980.js is disabled for leaking, see bug 711907
 
 libs::	$(_BROWSER_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
copy from browser/components/tabview/test/browser_tabview_bug650280.js
copy to browser/components/tabview/test/browser_tabview_bug650280_perwindowpb.js
--- a/browser/components/tabview/test/browser_tabview_bug650280.js
+++ b/browser/components/tabview/test/browser_tabview_bug650280_perwindowpb.js
@@ -1,67 +1,75 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-let pb = Cc["@mozilla.org/privatebrowsing;1"].
-         getService(Ci.nsIPrivateBrowsingService);
-
 function test() {
-  let cw;
-
-  registerCleanupFunction(function() {
-    if (cw)
-      cw.Search.hide();
-
-    TabView.hide();
-    pb.privateBrowsingEnabled = false;
-  });
-
-  let enableSearch = function (callback) {
-    if (cw.Search.isEnabled()) {
-      callback();
+  let enableSearch = function (aCW, aCallback) {
+    if (aCW.Search.isEnabled()) {
+       aCallback();
       return;
     }
 
-    cw.addEventListener("tabviewsearchenabled", function onSearchEnabled() {
-      cw.removeEventListener("tabviewsearchenabled", onSearchEnabled, false);
-      executeSoon(callback);
+    aCW.addEventListener("tabviewsearchenabled", function onSearchEnabled() {
+      aCW.removeEventListener("tabviewsearchenabled", onSearchEnabled, false);
+      executeSoon(aCallback);
     }, false);
 
-    cw.Search.ensureShown();
-  };
-
-  let getSearchboxValue = function () {
-    return cw.iQ("#searchbox").val();
+    aCW.Search.ensureShown();
   };
 
-  let prepareSearchbox = function (callback) {
-    ok(!cw.Search.isEnabled(), "search is disabled");
-
-    enableSearch(function () {
-      cw.iQ("#searchbox").val("moz");
-      callback();
-    });
+  let getSearchboxValue = function (aCW) {
+    return aCW.iQ("#searchbox").val();
   };
 
-  let searchAndSwitchPBMode = function (callback) {
-    prepareSearchbox(function () {
-      togglePrivateBrowsing(function () {
-        showTabView(function () {
-          ok(!cw.Search.isEnabled(), "search is disabled");
-          is(getSearchboxValue(), "", "search box is empty");
-          callback();
-        });
+  let prepareSearchbox = function (aCW, aCallback) {
+    ok(!aCW.Search.isEnabled(), "search is disabled");
+
+    executeSoon(function() {
+      enableSearch(aCW, function() {
+        aCW.iQ("#searchbox").val("moz");
+        aCallback();
       });
     });
   };
 
+  let searchAndSwitchPBMode = function (aWindow, aCallback) {
+    showTabView(function() {
+      let cw = aWindow.TabView.getContentWindow();
+
+      prepareSearchbox(cw, function() {
+        testOnWindow(!PrivateBrowsingUtils.isWindowPrivate(aWindow), function(win) {
+          showTabView(function() {
+            let contentWindow = win.TabView.getContentWindow();
+            ok(!contentWindow.Search.isEnabled(), "search is disabled");
+            is(getSearchboxValue(contentWindow), "", "search box is empty");
+            aWindow.TabView.hide();
+            win.close();
+            hideTabView(function() {
+              aWindow.close();
+              aCallback();
+            }, aWindow);
+          }, win);
+        });
+      });
+    }, aWindow);
+  };
+
+  let testOnWindow = function(aIsPrivate, aCallback) {
+    let win = OpenBrowserWindow({private: aIsPrivate});
+    win.addEventListener("load", function onLoad() {
+      win.removeEventListener("load", onLoad, false);
+      executeSoon(function() { aCallback(win) });
+    }, false);
+  }
+
   waitForExplicitFinish();
 
-  showTabView(function () {
-    cw = TabView.getContentWindow();
-    searchAndSwitchPBMode(function () {
-      searchAndSwitchPBMode(function () {
-        hideTabView(finish);
+  testOnWindow(false, function(win) {
+    searchAndSwitchPBMode(win, function() {
+      testOnWindow(true, function(win) {
+        searchAndSwitchPBMode(win, function() {
+          finish();
+        });
       });
     });
   });
 }