Wed, 31 Dec 2014 06:09:35 +0100
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();
7 newWindowWithTabView(function (win) {
8 registerCleanupFunction(function () win.close());
9 waitForFocus(function () testScenarios(win));
10 });
11 }
13 function testScenarios(win) {
14 let simulateDragDrop = function (target) {
15 EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw);
16 EventUtils.synthesizeMouse(target, 40, 20, {type: "mousemove"}, cw);
17 EventUtils.synthesizeMouse(target, 80, 20, {type: "mouseup"}, cw);
18 }
20 let dragOutOfGroup = function (target) {
21 EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw);
22 EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw);
23 EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw);
24 }
26 let dragIntoGroup = function (target) {
27 EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw);
28 EventUtils.synthesizeMouse(target, -200, 5, {type: "mousemove"}, cw);
29 EventUtils.synthesizeMouse(target, -200, 5, {type: "mouseup"}, cw);
30 }
32 let assertActiveOrphan = function (tabItem) {
33 ok(!cw.GroupItems.getActiveGroupItem(), "no groupItem is active");
34 is(cw.UI.getActiveTab(), tabItem, "orphan tab is active");
35 is(cw.UI.getActiveOrphanTab(), tabItem, "orphan tab is active");
36 }
38 let cw = win.TabView.getContentWindow();
39 let groupItem = cw.GroupItems.groupItems[0];
40 let groupItem2 = createGroupItemWithBlankTabs(win, 400, 300, 20, 4);
42 // move group
43 cw.UI.setActive(groupItem);
44 simulateDragDrop(groupItem2.container);
45 is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active");
46 is(cw.UI.getActiveTab(), groupItem2.getChild(0), "second groupItem's first tab is active");
48 // resize group
49 cw.UI.setActive(groupItem);
50 let tabItem = groupItem2.getChild(2);
51 groupItem2.setActiveTab(tabItem);
52 simulateDragDrop(groupItem2.$resizer[0]);
53 is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active");
54 is(cw.UI.getActiveTab(), tabItem, "second groupItem's third tab is active");
56 // drag tab out of group
57 tabItem = groupItem2.getChild(0);
58 dragOutOfGroup(tabItem.container);
59 is(cw.UI.getActiveTab(), tabItem, "the dragged tab is active");
61 // drag back into group
62 dragIntoGroup(tabItem.container);
63 cw.UI.setActive(groupItem);
64 cw.UI.setActive(groupItem2);
65 is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active");
67 // hide + unhide groupItem
68 hideGroupItem(groupItem2, function () {
69 is(cw.GroupItems.getActiveGroupItem(), groupItem, "first groupItem is active");
71 unhideGroupItem(groupItem2, function () {
72 is(cw.GroupItems.getActiveGroupItem(), groupItem2, "second groupItem is active");
73 is(cw.UI.getActiveTab(), tabItem, "the dropped tab is active");
75 finish();
76 });
77 });
78 }