browser/components/tabview/test/browser_tabview_bug630157.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 bounds = new cw.Rect(20, 20, 400, 200);
     9     let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true});
    11     let groupItemId = groupItem.id;
    12     registerCleanupFunction(function() {
    13       let groupItem = cw.GroupItems.groupItem(groupItemId);
    14       if (groupItem)
    15         groupItem.close();
    16     });
    18     return groupItem;
    19   }
    21   let assertNumberOfGroups = function (num) {
    22     is(cw.GroupItems.groupItems.length, num, 'there should be ' + num + ' groups');
    23   }
    25   let assertNumberOfTabs = function (num) {
    26     is(gBrowser.tabs.length, num, 'there should be ' + num + ' tabs');
    27   }
    29   let simulateDoubleClick = function (target, button) {
    30     for (let i=0; i<2; i++)
    31       EventUtils.synthesizeMouseAtCenter(target, {button: button || 0}, cw);
    32   }
    34   let finishTest = function () {
    35     let tabItem = gBrowser.tabs[0]._tabViewTabItem;
    36     cw.GroupItems.updateActiveGroupItemAndTabBar(tabItem);
    38     assertNumberOfGroups(1);
    39     assertNumberOfTabs(1);
    41     finish();
    42   }
    44   let testDoubleClick = function () {
    45     let groupItem = createGroupItem();
    46     assertNumberOfGroups(2);
    47     assertNumberOfTabs(1);
    49     // simulate double click on group title
    50     let input = groupItem.$title[0];
    51     simulateDoubleClick(input);
    52     assertNumberOfTabs(1);
    54     // simulate double click on title bar
    55     let titlebar = groupItem.$titlebar[0];
    56     simulateDoubleClick(titlebar);
    57     assertNumberOfTabs(1);
    59     // simulate double click with middle mouse button
    60     let container = groupItem.container;
    61     simulateDoubleClick(container, 1);
    62     assertNumberOfTabs(1);
    64     // simulate double click with right mouse button
    65     simulateDoubleClick(container, 2);
    66     assertNumberOfTabs(1);
    68     groupItem.close();
    69     hideTabView(finishTest);
    70   }
    72   waitForExplicitFinish();
    73   registerCleanupFunction(function () TabView.hide());
    75   showTabView(function () {
    76     cw = TabView.getContentWindow();
    77     testDoubleClick();
    78   });
    79 }

mercurial