browser/components/tabview/test/browser_tabview_bug607108.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:b5a090a30698
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 function test() {
5 let cw;
6
7 let assertNumberOfGroupItems = function (num) {
8 let groupItems = cw.GroupItems.groupItems;
9 is(groupItems.length, num, "number of groupItems is " + num);
10 };
11
12 let dragTabOutOfGroup = function (groupItem) {
13 let tabItem = groupItem.getChild(0);
14 let target = tabItem.container;
15
16 EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw);
17 EventUtils.synthesizeMouse(target, 400, 100, {type: "mousemove"}, cw);
18 EventUtils.synthesizeMouseAtCenter(target, {type: "mouseup"}, cw);
19 };
20
21 let testCreateGroup = function (callback) {
22 let content = cw.document.getElementById("content");
23
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);
28
29 assertNumberOfGroupItems(2);
30
31 // enter a title for the new group
32 EventUtils.synthesizeKey("t", {}, cw);
33 EventUtils.synthesizeKey("VK_RETURN", {}, cw);
34
35
36 let groupItem = cw.GroupItems.groupItems[1];
37 is(groupItem.getTitle(), "t", "new groupItem's title is correct");
38
39 closeGroupItem(groupItem, callback);
40 };
41
42 let testDragOutOfGroup = function (callback) {
43 assertNumberOfGroupItems(1);
44
45 let groupItem = cw.GroupItems.groupItems[0];
46 dragTabOutOfGroup(groupItem);
47 assertNumberOfGroupItems(2);
48
49 // enter a title for the new group
50 EventUtils.synthesizeKey("t", {}, cw);
51 EventUtils.synthesizeKey("VK_RETURN", {}, cw);
52
53 groupItem = cw.GroupItems.groupItems[1];
54 is(groupItem.getTitle(), "t", "new groupItem's title is correct");
55 closeGroupItem(groupItem, callback);
56 };
57
58 let onLoad = function (win) {
59 registerCleanupFunction(function () win.close());
60
61 for (let i = 0; i < 2; i++)
62 win.gBrowser.addTab();
63 };
64
65 let onShow = function (win) {
66 cw = win.TabView.getContentWindow();
67 assertNumberOfGroupItems(1);
68
69 let groupItem = cw.GroupItems.groupItems[0];
70 groupItem.setSize(200, 600, true);
71
72 waitForFocus(function () {
73 testCreateGroup(function () {
74 testDragOutOfGroup(finish);
75 });
76 }, cw);
77 };
78
79 waitForExplicitFinish();
80 newWindowWithTabView(onShow, onLoad);
81 }

mercurial