browser/components/tabview/test/browser_tabview_bug627736.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   waitForExplicitFinish();
     6   newWindowWithTabView(onTabViewWindowLoaded);
     7 }
     9 function onTabViewWindowLoaded(win) {
    10   ok(win.TabView.isVisible(), "Tab View is visible");
    12   let contentWindow = win.document.getElementById("tab-view").contentWindow;
    13   let [originalTab] = win.gBrowser.visibleTabs;
    14   let originalGroup = contentWindow.GroupItems.getActiveGroupItem();
    16   // open a group with a tab, and close either the group or the tab.
    17   function openAndClose(groupOrTab, callback) {
    18     // let's create a group with a tab.
    19     let group = new contentWindow.GroupItem([], {
    20       immediately: true,
    21       bounds: {left: 20, top: 20, width: 400, height: 400}
    22     });
    23     contentWindow.UI.setActive(group);
    24     win.gBrowser.loadOneTab('about:blank', {inBackground: true});
    26     is(group.getChildren().length, 1, "The group has one child now.");
    27     let tab = group.getChild(0);
    29     function check() {
    30       if (groupOrTab == 'group') {
    31         group.removeSubscriber("groupHidden", check);
    32         group.closeHidden();
    33       } else
    34         tab.removeSubscriber("tabRemoved", check);
    36       is(contentWindow.GroupItems.getActiveGroupItem(), originalGroup,
    37         "The original group is active.");
    38       is(contentWindow.UI.getActiveTab(), originalTab._tabViewTabItem,
    39         "The original tab is active");
    41       callback();
    42     }
    44     if (groupOrTab == 'group') {
    45       group.addSubscriber("groupHidden", check);
    46       group.closeAll();
    47     } else {
    48       tab.addSubscriber("tabRemoved", check);
    49       tab.close();
    50     }
    51   }
    53   // PHASE 1: create a group with a tab and close the group.
    54   openAndClose("group", function postPhase1() {
    55     // PHASE 2: create a group with a tab and close the tab.
    56     openAndClose("tab", function postPhase2() {
    57       win.close();
    58       finish();
    59     });
    60   });
    61 }

mercurial