Bug 651114 - Clean up browser_tabview_bug612470.js [f=raymond, r=ian]
authorTim Taubert <tim.taubert@gmx.de>
Fri, 22 Apr 2011 20:03:44 +0200
changeset 68479 7b7a77e74c7874f215a1020cf434dd6059be3a5f
parent 68478 5bb9cd5c939a44d93b8eaca32fc502702bdc59b6
child 68480 8a822b2befc3faaeee2f9b9dbc6d7fb8e2a97b9f
push id19658
push userMs2ger@gmail.com
push dateSun, 24 Apr 2011 06:58:13 +0000
treeherdermozilla-central@7b7a77e74c78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersian
bugs651114, 612470
milestone6.0a1
first release with
nightly linux32
7b7a77e74c78 / 6.0a1 / 20110424030527 / files
nightly linux64
7b7a77e74c78 / 6.0a1 / 20110424030527 / files
nightly mac
7b7a77e74c78 / 6.0a1 / 20110424030527 / files
nightly win32
7b7a77e74c78 / 6.0a1 / 20110424030527 / files
nightly win64
7b7a77e74c78 / 6.0a1 / 20110424030208 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 651114 - Clean up browser_tabview_bug612470.js [f=raymond, r=ian]
browser/base/content/test/tabview/browser_tabview_bug612470.js
--- a/browser/base/content/test/tabview/browser_tabview_bug612470.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug612470.js
@@ -1,76 +1,48 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests that groups behave properly when closing all tabs but app tabs.
 
-let appTab, contentWindow;
-let originalGroup, originalGroupTab, newGroup, newGroupTab;
+function test() {
+  let cw, win, groupItem;
+
+  let onLoad = function (tvwin) {
+    win = tvwin;
+    registerCleanupFunction(function () win.close());
+    win.gBrowser.pinTab(win.gBrowser.tabs[0]);
+    win.gBrowser.loadOneTab("about:blank", {inBackground: true});
+  };
+
+  let onShow = function () {
+    cw = win.TabView.getContentWindow();
+    is(cw.GroupItems.groupItems.length, 1, "There's only one group");
+
+    groupItem = createEmptyGroupItem(cw, 200, 200, 20);
+    cw.GroupItems.setActiveGroupItem(groupItem);
+
+    executeSoon(function () hideTabView(onHide, win));
+  };
 
-function test() {
+  let onHide = function () {
+    let tab = win.gBrowser.loadOneTab("about:blank", {inBackground: true});
+    is(groupItem.getChildren().length, 1, "One tab is in the new group");
+
+    executeSoon(function () {
+      is(win.gBrowser.visibleTabs.length, 2, "There are two tabs displayed");
+      win.gBrowser.removeTab(tab);
+
+      is(groupItem.getChildren().length, 0, "No tabs are in the new group");
+      is(win.gBrowser.visibleTabs.length, 1, "There is one tab displayed");
+      is(cw.GroupItems.groupItems.length, 2, "There are two groups still");
+
+      showTabView(function () {
+        is(cw.GroupItems.groupItems.length, 1, "There is now only one group");
+        waitForFocus(finish);
+      }, win);
+    });
+  };
+
   waitForExplicitFinish();
 
-  appTab = gBrowser.selectedTab;
-  gBrowser.pinTab(appTab);
-  originalGroupTab = gBrowser.addTab();
-
-  addEventListener("tabviewshown", createGroup, false);
-  TabView.toggle();
-}
-
-function createGroup() {
-  removeEventListener("tabviewshown", createGroup, false);
-
-  contentWindow = document.getElementById("tab-view").contentWindow;
-  is(contentWindow.GroupItems.groupItems.length, 1, "There's only one group");
-
-  originalGroup = contentWindow.GroupItems.groupItems[0];
-
-  // Create a new group.
-  let box = new contentWindow.Rect(20, 400, 300, 300);
-  newGroup = new contentWindow.GroupItem([], { bounds: box });
-
-  contentWindow.GroupItems.setActiveGroupItem(newGroup);
-
-  addEventListener("tabviewhidden", addTab, false);
-  TabView.toggle();
-}
-
-function addTab() {
-  removeEventListener("tabviewhidden", addTab, false);
-
-  newGroupTab = gBrowser.addTab();
-  is(newGroup.getChildren().length, 1, "One tab is in the new group");
-  executeSoon(removeTab);
+  newWindowWithTabView(onShow, onLoad);
 }
-
-function removeTab() {
-  is(gBrowser.visibleTabs.length, 2, "There are two tabs displayed");
-  gBrowser.removeTab(newGroupTab);
-
-  is(newGroup.getChildren().length, 0, "No tabs are in the new group");
-  is(gBrowser.visibleTabs.length, 1, "There is one tab displayed");
-  is(contentWindow.GroupItems.groupItems.length, 2,
-     "There are two groups still");
-
-  addEventListener("tabviewshown", checkForRemovedGroup, false);
-  TabView.toggle();
-}
-
-function checkForRemovedGroup() {
-  removeEventListener("tabviewshown", checkForRemovedGroup, false);
-
-  is(contentWindow.GroupItems.groupItems.length, 1,
-     "There is now only one group");
-
-  addEventListener("tabviewhidden", finishTest, false);
-  TabView.toggle();
-}
-
-function finishTest() {
-  removeEventListener("tabviewhidden", finishTest, false);
-
-  gBrowser.removeTab(originalGroupTab);
-  gBrowser.unpinTab(appTab);
-  finish();
-}
-