browser/components/tabview/test/browser_tabview_bug663421.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 win, cw, groupItem;
     7   function checkNumberOfGroupItems(num) {
     8     is(cw.GroupItems.groupItems.length, num, "there are " + num + " groupItems");
     9   }
    11   function next() {
    12     if (tests.length)
    13       tests.shift()();
    14     else
    15       finish();
    16   }
    18   // Empty groups should not be closed when toggling Panorama on and off.
    19   function test1() {
    20     hideTabView(function () {
    21       showTabView(function () {
    22         checkNumberOfGroupItems(2);
    23         next();
    24       }, win);
    25     }, win);
    26   }
    28   // Groups should not be closed when their last tab is closed outside of Panorama.
    29   function test2() {
    30     whenTabViewIsHidden(function () {
    31       whenTabViewIsShown(function () {
    32         checkNumberOfGroupItems(2);
    33         next();
    34       }, win);
    36       win.gBrowser.removeTab(win.gBrowser.selectedTab);
    37     }, win);
    39     groupItem.newTab();
    40   }
    42   // Groups should be closed when their last tab is closed.
    43   function test3() {
    44     whenTabViewIsHidden(function () {
    45       showTabView(function () {
    46         let tab = win.gBrowser.tabs[1];
    47         tab._tabViewTabItem.close();
    48         checkNumberOfGroupItems(1);
    49         next();
    50       }, win);
    51     }, win);
    53     win.gBrowser.addTab();
    54   }
    56   // Groups should be closed when their last tab is dragged out.
    57   function test4() {
    58     groupItem = createGroupItemWithBlankTabs(win, 200, 200, 20, 1);
    59     checkNumberOfGroupItems(2);
    61     let tab = win.gBrowser.tabs[1];
    62     let target = tab._tabViewTabItem.container;
    64     waitForFocus(function () {
    65       EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw);
    66       EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw);
    67       EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw);
    69       checkNumberOfGroupItems(2);
    70       closeGroupItem(cw.GroupItems.groupItems[1], next);
    71     }, win);
    72   }
    74   let tests = [test1, test2, test3, test4];
    76   waitForExplicitFinish();
    78   newWindowWithTabView(function (aWin) {
    79     registerCleanupFunction(function () aWin.close());
    81     win = aWin;
    82     cw = win.TabView.getContentWindow();
    83     groupItem = createEmptyGroupItem(cw, 200, 200, 20);
    85     checkNumberOfGroupItems(2);
    86     next();
    87   });
    88 }

mercurial