browser/components/tabview/test/browser_tabview_bug635696.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 function test() {
     5   let cw;
     7   let createGroupItem = function () {
     8     let groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1);
    10     let groupItemId = groupItem.id;
    11     registerCleanupFunction(function() {
    12       let groupItem = cw.GroupItems.groupItem(groupItemId);
    13       if (groupItem)
    14         groupItem.close();
    15     });
    17     return groupItem;
    18   }
    20   let testSingleGroupItem = function () {
    21     let groupItem = cw.GroupItems.groupItems[0];
    22     is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is active");
    24     let tabItem = groupItem.getChild(0);
    25     is(cw.UI.getActiveTab(), tabItem, "tabItem is active");
    27     hideGroupItem(groupItem, function () {
    28       unhideGroupItem(groupItem, function () {
    29         is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is still active");
    30         is(cw.UI.getActiveTab(), tabItem, "tabItem is still active");
    31         next();
    32       });
    33     });
    34   }
    36   let testTwoGroupItems = function () {
    37     let groupItem = cw.GroupItems.groupItems[0];
    38     let tabItem = groupItem.getChild(0);
    40     let groupItem2 = createGroupItem();
    41     let tabItem2 = groupItem2.getChild(0);
    43     hideGroupItem(groupItem, function () {
    44       is(cw.UI.getActiveTab(), tabItem2, "tabItem2 is active");
    45       unhideGroupItem(groupItem, function () {
    46         cw.UI.setActive(tabItem);
    47         closeGroupItem(groupItem2, next);
    48       });
    49     });
    50   }
    52   let tests = [testSingleGroupItem, testTwoGroupItems];
    54   let next = function () {
    55     let test = tests.shift();
    56     if (test)
    57       test();
    58     else
    59       hideTabView(finishTest);
    60   }
    62   let finishTest = function () {
    63     is(cw.GroupItems.groupItems.length, 1, "there is one groupItem");
    64     is(gBrowser.tabs.length, 1, "there is one tab");
    65     ok(!TabView.isVisible(), "tabview is hidden");
    67     finish();
    68   }
    70   waitForExplicitFinish();
    72   showTabView(function () {
    73     registerCleanupFunction(function () TabView.hide());
    74     cw = TabView.getContentWindow();
    75     next();
    76   });
    77 }

mercurial