browser/components/tabview/test/browser_tabview_bug588265.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 contentWindow;
     5 let groupItemTwoId;
     7 function test() {
     8   waitForExplicitFinish();
    10   registerCleanupFunction(function() {
    11     while (gBrowser.tabs[1])
    12       gBrowser.removeTab(gBrowser.tabs[1]);
    13     hideTabView();
    14   });
    15   gBrowser.loadOneTab("about:blank", { inBackground: true });
    16   showTabView(setup);
    17 }
    19 function setup() {
    20   registerCleanupFunction(function() {
    21     let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
    22     if (groupItem)
    23       closeGroupItem(groupItem);
    24   });
    26   let contentWindow = TabView.getContentWindow();
    27   is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
    29   let groupItemOne = contentWindow.GroupItems.groupItems[0];
    30   is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items");
    32   let groupItemTwo = createGroupItemWithBlankTabs(window, 250, 250, 40, 1);
    33   groupItemTwoId = groupItemTwo.id;
    34   testGroups(groupItemOne, groupItemTwo, contentWindow);
    35 }
    37 function testGroups(groupItemOne, groupItemTwo, contentWindow) {
    38   // check active tab and group
    39   is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo, 
    40      "The group two is the active group");
    41   is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(0), 
    42      "The first tab item in group two is active");
    44   let tabItem = groupItemOne.getChild(1);
    45   tabItem.addSubscriber("tabRemoved", function onTabRemoved() {
    46     tabItem.removeSubscriber("tabRemoved", onTabRemoved);
    48     is(groupItemOne.getChildren().length, 1,
    49       "The num of childen in group one is 1");
    51     // check active group and active tab
    52     is(contentWindow.GroupItems.getActiveGroupItem(), groupItemOne, 
    53        "The group one is the active group");
    54     is(contentWindow.UI.getActiveTab(), groupItemOne.getChild(0), 
    55        "The first tab item in group one is active");
    57     whenTabViewIsHidden(function() {
    58       is(groupItemOne.getChildren().length, 2, 
    59          "The num of childen in group one is 2");
    61       // clean up and finish
    62       closeGroupItem(groupItemTwo, function() {
    63         gBrowser.removeTab(groupItemOne.getChild(1).tab);
    64         is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
    65         is(groupItemOne.getChildren().length, 1, 
    66            "The num of childen in group one is 1");
    67         is(gBrowser.tabs.length, 1, "Has only one tab");
    69         finish();
    70       });
    71     });
    72     EventUtils.synthesizeKey("t", { accelKey: true });
    73   });
    74   // close a tab item in group one
    75    EventUtils.synthesizeMouseAtCenter(tabItem.$close[0], {}, contentWindow);
    76 }

mercurial