|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 waitForExplicitFinish(); |
|
6 |
|
7 let tContextMenu = document.getElementById("tabContextMenu"); |
|
8 let tvMenuPopup = document.getElementById("context_tabViewMenuPopup"); |
|
9 let group1; |
|
10 let group2; |
|
11 |
|
12 function openMoveToGroupPopup() { |
|
13 let tab = gBrowser.selectedTab; |
|
14 let tvMenu = document.getElementById("context_tabViewMenu"); |
|
15 let tvMenuPopup = document.getElementById("context_tabViewMenuPopup"); |
|
16 let tvEvent = new Event(""); |
|
17 |
|
18 tab.dispatchEvent(tvEvent); |
|
19 tContextMenu.openPopup(tab, "end_after", 0, 0, true, false, tvEvent); |
|
20 tvMenuPopup.openPopup(tvMenu, "end_after", 0, 0, true, false); |
|
21 } |
|
22 |
|
23 function hideMoveToGroupPopup() { |
|
24 tvMenuPopup.hidePopup(); |
|
25 tContextMenu.hidePopup(); |
|
26 } |
|
27 |
|
28 function createGroups() { |
|
29 let cw = TabView.getContentWindow(); |
|
30 |
|
31 group1 = createGroupItemWithTabs(window, 200, 200, 20, ["about:blank"]); |
|
32 group1.setTitle("group with items and title"); |
|
33 group2 = createEmptyGroupItem(cw, 200, 200, 20); |
|
34 cw.UI.setActive(cw.GroupItems.groupItems[0]); |
|
35 |
|
36 // Check the group count. |
|
37 is(cw.GroupItems.groupItems.length, 3, "Validate group count in tab view."); |
|
38 |
|
39 hideTabView(checkGroupMenuItems); |
|
40 } |
|
41 |
|
42 // The group count includes the separator and the 'new group' menu item. |
|
43 function checkGroupMenuItems() { |
|
44 // First test with an empty untitled group. |
|
45 openMoveToGroupPopup(); |
|
46 is(tvMenuPopup.childNodes.length, 3, "Validate group item count in move to group popup."); |
|
47 hideMoveToGroupPopup(); |
|
48 |
|
49 // Then test with an empty but titled group. |
|
50 group2.setTitle("empty group with title"); |
|
51 openMoveToGroupPopup(); |
|
52 is(tvMenuPopup.childNodes.length, 4, "Validate group item count in move to group popup."); |
|
53 hideMoveToGroupPopup(); |
|
54 |
|
55 // Clean |
|
56 closeGroupItem(group1, function() { closeGroupItem(group2, finish); }); |
|
57 } |
|
58 |
|
59 showTabView(createGroups); |
|
60 } |
|
61 |