browser/components/tabview/test/browser_tabview_bug607108.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 assertNumberOfGroupItems = function (num) {
     8     let groupItems = cw.GroupItems.groupItems;
     9     is(groupItems.length, num, "number of groupItems is " + num);
    10   };
    12   let dragTabOutOfGroup = function (groupItem) {
    13     let tabItem = groupItem.getChild(0);
    14     let target = tabItem.container;
    16     EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw);
    17     EventUtils.synthesizeMouse(target, 400, 100, {type: "mousemove"}, cw);
    18     EventUtils.synthesizeMouseAtCenter(target, {type: "mouseup"}, cw);
    19   };
    21   let testCreateGroup = function (callback) {
    22     let content = cw.document.getElementById("content");
    24     // drag to create a new group
    25     EventUtils.synthesizeMouse(content, 400, 50, {type: "mousedown"}, cw);
    26     EventUtils.synthesizeMouse(content, 500, 250, {type: "mousemove"}, cw);
    27     EventUtils.synthesizeMouse(content, 500, 250, {type: "mouseup"}, cw);
    29     assertNumberOfGroupItems(2);
    31     // enter a title for the new group
    32     EventUtils.synthesizeKey("t", {}, cw);
    33     EventUtils.synthesizeKey("VK_RETURN", {}, cw);
    36     let groupItem = cw.GroupItems.groupItems[1];
    37     is(groupItem.getTitle(), "t", "new groupItem's title is correct");
    39     closeGroupItem(groupItem, callback);
    40   };
    42   let testDragOutOfGroup = function (callback) {
    43     assertNumberOfGroupItems(1);
    45     let groupItem = cw.GroupItems.groupItems[0];
    46     dragTabOutOfGroup(groupItem);
    47     assertNumberOfGroupItems(2);
    49     // enter a title for the new group
    50     EventUtils.synthesizeKey("t", {}, cw);
    51     EventUtils.synthesizeKey("VK_RETURN", {}, cw);
    53     groupItem = cw.GroupItems.groupItems[1];
    54     is(groupItem.getTitle(), "t", "new groupItem's title is correct");
    55     closeGroupItem(groupItem, callback);
    56   };
    58   let onLoad = function (win) {
    59     registerCleanupFunction(function () win.close());
    61     for (let i = 0; i < 2; i++)
    62       win.gBrowser.addTab();
    63   };
    65   let onShow = function (win) {
    66     cw = win.TabView.getContentWindow();
    67     assertNumberOfGroupItems(1);
    69     let groupItem = cw.GroupItems.groupItems[0];
    70     groupItem.setSize(200, 600, true);
    72     waitForFocus(function () {
    73       testCreateGroup(function () {
    74         testDragOutOfGroup(finish);
    75       });
    76     }, cw);
    77   };
    79   waitForExplicitFinish();
    80   newWindowWithTabView(onShow, onLoad);
    81 }

mercurial