browser/components/tabview/test/browser_tabview_bug590606.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 let originalTab;
     5 let newTabOne;
     6 let groupItemTwoId;
     8 function test() {
     9   waitForExplicitFinish();
    11   originalTab = gBrowser.visibleTabs[0];
    12   // add a tab to the existing group.
    13   newTabOne = gBrowser.addTab();
    15   registerCleanupFunction(function() {
    16     while (gBrowser.tabs[1])
    17       gBrowser.removeTab(gBrowser.tabs[1]);
    18     hideTabView();
    19   });
    21   showTabView(function() {
    22     let contentWindow = TabView.getContentWindow();
    24     registerCleanupFunction(function() {
    25       let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
    26       if (groupItem)
    27         closeGroupItem(groupItem);
    28     });
    30     is(contentWindow.GroupItems.groupItems.length, 1, 
    31        "There is one group item on startup");
    32     let groupItemOne = contentWindow.GroupItems.groupItems[0];
    33     is(groupItemOne.getChildren().length, 2, 
    34        "There should be two tab items in that group.");
    35     is(gBrowser.selectedTab, groupItemOne.getChild(0).tab,
    36        "The currently selected tab should be the first tab in the groupItemOne");
    38     // create another group with a tab.
    39     let groupItemTwo = createGroupItemWithBlankTabs(window, 300, 300, 200, 1);
    40     groupItemTwoId = groupItemTwoId;
    41     hideTabView(function() {
    42       // start the test
    43       testGroupSwitch(contentWindow, groupItemOne, groupItemTwo);
    44     });
    45   });
    46 }
    48 function testGroupSwitch(contentWindow, groupItemOne, groupItemTwo) {
    49   is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab,
    50      "The currently selected tab should be the only tab in the groupItemTwo");
    52   // switch to groupItemOne
    53   let tabItem = contentWindow.GroupItems.getNextGroupItemTab(false);
    54   if (tabItem)
    55     gBrowser.selectedTab = tabItem.tab;
    56   is(gBrowser.selectedTab, groupItemOne.getChild(0).tab,
    57     "The currently selected tab should be the first tab in the groupItemOne");
    59   // switch to the second tab in groupItemOne
    60   gBrowser.selectedTab = groupItemOne.getChild(1).tab;
    62   // switch to groupItemTwo
    63   tabItem = contentWindow.GroupItems.getNextGroupItemTab(false);
    64   if (tabItem)
    65     gBrowser.selectedTab = tabItem.tab;
    66   is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab,
    67     "The currently selected tab should be the only tab in the groupItemTwo");
    69   // switch to groupItemOne
    70   tabItem = contentWindow.GroupItems.getNextGroupItemTab(false);
    71   if (tabItem)
    72     gBrowser.selectedTab = tabItem.tab;
    73   is(gBrowser.selectedTab, groupItemOne.getChild(1).tab,
    74     "The currently selected tab should be the second tab in the groupItemOne");
    76   // cleanup.
    77   gBrowser.removeTab(groupItemTwo.getChild(0).tab);
    78   gBrowser.removeTab(newTabOne);
    80   finish();
    81 }

mercurial