browser/components/tabview/test/browser_tabview_bug649006.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:5ea8315e0f90
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;
6
7 function test() {
8 waitForExplicitFinish();
9
10 registerCleanupFunction(function () {
11 hideTabView();
12 });
13
14 showTabView(function() {
15 contentWindow = TabView.getContentWindow();
16 contentElement = contentWindow.document.getElementById("content");
17 test1();
18 });
19 }
20
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);
28
29 is(gBrowser.tabs.length, 1,
30 "Total number of tabs is 1 after right button double click");
31 test2();
32 }
33
34
35 function test2() {
36 is(gBrowser.tabs.length, 1,
37 "Total number of tabs is 1 before left, right and left mouse clicks");
38
39 // first click
40 mouseClick(contentElement, 0);
41 // second click
42 mouseClick(contentElement, 2);
43 // third click
44 mouseClick(contentElement, 0);
45
46 is(gBrowser.tabs.length, 1,
47 "Total number of tabs is 1 before left, right and left mouse clicks");
48 test3();
49 }
50
51 function test3() {
52 ok(contentWindow.GroupItems.groupItems.length, 1, "Only one group item exists");
53 groupItem = contentWindow.GroupItems.groupItems[0];
54
55 is(groupItem.getChildren().length, 1,
56 "The number of tab items in the group is 1 before right button double click");
57
58 // first click
59 mouseClick(groupItem.container, 2);
60 // second click
61 mouseClick(groupItem.container, 2);
62
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 }
67
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");
71
72 // first click
73 mouseClick(groupItem.container, 0);
74 // second click
75 mouseClick(groupItem.container, 2);
76 // third click
77 mouseClick(groupItem.container, 0);
78
79 is(groupItem.getChildren().length, 1,
80 "The number of tab items in the group is 1 before left, right, left mouse clicks");
81
82 hideTabView(function() {
83 is(gBrowser.tabs.length, 1, "Total number of tabs is 1 after all tests");
84
85 contentWindow = null;
86 contentElement = null;
87 groupItem = null;
88
89 finish();
90 });
91 }
92
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 }
99

mercurial