browser/components/tabview/test/browser_tabview_bug649006.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/ */
     3 let contentWindow;
     4 let contentElement;
     5 let groupItem;
     7 function test() {
     8   waitForExplicitFinish();
    10   registerCleanupFunction(function () {
    11     hideTabView();
    12   });
    14   showTabView(function() {
    15     contentWindow = TabView.getContentWindow();
    16     contentElement = contentWindow.document.getElementById("content");
    17     test1();
    18   });
    19 }
    21 function test1() {
    22   is(gBrowser.tabs.length, 1, 
    23      "Total number of tabs is 1 before right button double click");
    24   // first click
    25   mouseClick(contentElement, 2);
    26   // second click
    27   mouseClick(contentElement, 2);
    29   is(gBrowser.tabs.length, 1, 
    30      "Total number of tabs is 1 after right button double click");
    31   test2();
    32 }
    35 function test2() {
    36   is(gBrowser.tabs.length, 1, 
    37      "Total number of tabs is 1 before left, right and left mouse clicks");
    39   // first click
    40   mouseClick(contentElement, 0);
    41   // second click
    42   mouseClick(contentElement, 2);
    43   // third click
    44   mouseClick(contentElement, 0);
    46   is(gBrowser.tabs.length, 1, 
    47      "Total number of tabs is 1 before left, right and left mouse clicks");
    48   test3();
    49 }
    51 function test3() {
    52   ok(contentWindow.GroupItems.groupItems.length, 1, "Only one group item exists");
    53   groupItem = contentWindow.GroupItems.groupItems[0];
    55   is(groupItem.getChildren().length, 1, 
    56      "The number of tab items in the group is 1 before right button double click");
    58   // first click
    59   mouseClick(groupItem.container, 2);
    60   // second click
    61   mouseClick(groupItem.container, 2);
    63   is(groupItem.getChildren().length, 1, 
    64      "The number of tab items in the group is 1 after right button double click");
    65   test4();
    66 }
    68 function test4() {
    69   is(groupItem.getChildren().length, 1, 
    70      "The number of tab items in the group is 1 before left, right, left mouse clicks");
    72   // first click
    73   mouseClick(groupItem.container, 0);
    74   // second click
    75   mouseClick(groupItem.container, 2);
    76   // third click
    77   mouseClick(groupItem.container, 0);
    79   is(groupItem.getChildren().length, 1, 
    80      "The number of tab items in the group is 1 before left, right, left mouse clicks");
    82   hideTabView(function() {
    83     is(gBrowser.tabs.length, 1, "Total number of tabs is 1 after all tests");
    85     contentWindow = null;
    86     contentElement = null;
    87     groupItem = null;
    89     finish();
    90   });
    91 }
    93 function mouseClick(targetElement, buttonCode) {
    94   EventUtils.sendMouseEvent(
    95     { type: "mousedown", button: buttonCode }, targetElement, contentWindow);
    96   EventUtils.sendMouseEvent(
    97     { type: "mouseup", button: buttonCode }, targetElement, contentWindow);
    98 }

mercurial