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 registerCleanupFunction(function() {
8 while (gBrowser.tabs[1])
9 gBrowser.removeTab(gBrowser.tabs[1]);
10 hideTabView();
11 });
12 showTabView(onTabViewWindowLoaded);
13 }
15 function onTabViewWindowLoaded() {
16 ok(TabView.isVisible(), "Tab View is visible");
18 let contentWindow = TabView.getContentWindow();
20 registerCleanupFunction(function() {
21 let groupItem = contentWindow.GroupItems.groupItem(groupItemId);
22 if (groupItem)
23 closeGroupItem(groupItem);
24 });
26 // create a group item
27 let groupItem = createGroupItemWithBlankTabs(window, 300, 300, 400, 1);
28 let groupItemId = groupItem.id;
29 is(groupItem.getChildren().length, 1, "The new group has a tab item");
30 // start the tests
31 waitForFocus(function() {
32 testUndoGroup(contentWindow, groupItem);
33 }, contentWindow);
34 }
36 function testUndoGroup(contentWindow, groupItem) {
37 groupItem.addSubscriber("groupHidden", function onHidden() {
38 groupItem.removeSubscriber("groupHidden", onHidden);
40 // check the data of the group
41 let theGroupItem = contentWindow.GroupItems.groupItem(groupItem.id);
42 ok(theGroupItem, "The group item still exists");
43 is(theGroupItem.getChildren().length, 1,
44 "The tab item in the group still exists");
46 // check the visibility of the group element and undo element
47 is(theGroupItem.container.style.display, "none",
48 "The group element is hidden");
49 ok(theGroupItem.$undoContainer, "Undo container is avaliable");
51 EventUtils.sendMouseEvent(
52 { type: "click" }, theGroupItem.$undoContainer[0], contentWindow);
53 });
55 groupItem.addSubscriber("groupShown", function onShown() {
56 groupItem.removeSubscriber("groupShown", onShown);
58 // check the data of the group
59 let theGroupItem = contentWindow.GroupItems.groupItem(groupItem.id);
60 ok(theGroupItem, "The group item still exists");
61 is(theGroupItem.getChildren().length, 1,
62 "The tab item in the group still exists");
64 // check the visibility of the group element and undo element
65 is(theGroupItem.container.style.display, "", "The group element is visible");
66 ok(!theGroupItem.$undoContainer, "Undo container is not avaliable");
68 // start the next test
69 testCloseUndoGroup(contentWindow, groupItem);
70 });
72 let closeButton = groupItem.container.getElementsByClassName("close");
73 ok(closeButton[0], "Group item close button exists");
74 EventUtils.sendMouseEvent({ type: "click" }, closeButton[0], contentWindow);
75 }
77 function testCloseUndoGroup(contentWindow, groupItem) {
78 groupItem.addSubscriber("groupHidden", function onHidden() {
79 groupItem.removeSubscriber("groupHidden", onHidden);
81 // check the data of the group
82 let theGroupItem = contentWindow.GroupItems.groupItem(groupItem.id);
83 ok(theGroupItem, "The group item still exists");
84 is(theGroupItem.getChildren().length, 1,
85 "The tab item in the group still exists");
87 // check the visibility of the group element and undo element
88 is(theGroupItem.container.style.display, "none",
89 "The group element is hidden");
90 ok(theGroupItem.$undoContainer, "Undo container is avaliable");
92 // click on close
93 let closeButton = theGroupItem.$undoContainer.find(".close");
94 EventUtils.sendMouseEvent(
95 { type: "click" }, closeButton[0], contentWindow);
96 });
98 groupItem.addSubscriber("close", function onClose() {
99 groupItem.removeSubscriber("close", onClose);
101 let theGroupItem = contentWindow.GroupItems.groupItem(groupItem.id);
102 ok(!theGroupItem, "The group item doesn't exists");
104 // after the last selected tabitem is closed, there would be not active
105 // tabitem on the UI so we set the active tabitem before toggling the
106 // visibility of tabview
107 let tabItems = contentWindow.TabItems.getItems();
108 ok(tabItems[0], "A tab item exists");
109 contentWindow.UI.setActive(tabItems[0]);
111 hideTabView(function() {
112 ok(!TabView.isVisible(), "Tab View is hidden");
113 finish();
114 });
115 });
117 let closeButton = groupItem.container.getElementsByClassName("close");
118 ok(closeButton[0], "Group item close button exists");
119 EventUtils.sendMouseEvent({ type: "click" }, closeButton[0], contentWindow);
120 }