|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 let openMoveToGroupPopup = function () { |
|
6 let tab = gBrowser.selectedTab; |
|
7 var evt = new Event(""); |
|
8 tab.dispatchEvent(evt); |
|
9 contextMenu.openPopup(tab, "end_after", 0, 0, true, false, evt); |
|
10 tvMenuPopup.openPopup(tvMenu, "end_after", 0, 0, true, false); |
|
11 } |
|
12 |
|
13 let hideMoveToGroupPopup = function () { |
|
14 tvMenuPopup.hidePopup(); |
|
15 contextMenu.hidePopup(); |
|
16 } |
|
17 |
|
18 let assertValidPrerequisites = function (visible) { |
|
19 let cw = TabView.getContentWindow(); |
|
20 is(cw.GroupItems.groupItems.length, 1, "there is one groupItem"); |
|
21 is(gBrowser.tabs.length, 1, "there is one tab"); |
|
22 is(TabView.isVisible(), visible, "tabview is visible"); |
|
23 } |
|
24 |
|
25 let tvMenu = document.getElementById("context_tabViewMenu"); |
|
26 let contextMenu = document.getElementById("tabContextMenu"); |
|
27 let tvMenuPopup = document.getElementById("context_tabViewMenuPopup"); |
|
28 |
|
29 waitForExplicitFinish(); |
|
30 |
|
31 registerCleanupFunction(function () { |
|
32 hideMoveToGroupPopup(); |
|
33 hideTabView(); |
|
34 |
|
35 let groupItems = TabView.getContentWindow().GroupItems.groupItems; |
|
36 if (groupItems.length > 1) |
|
37 closeGroupItem(groupItems[0]); |
|
38 }); |
|
39 |
|
40 showTabView(function () { |
|
41 assertValidPrerequisites(true); |
|
42 |
|
43 hideTabView(function () { |
|
44 let groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1); |
|
45 groupItem.setTitle("group2"); |
|
46 |
|
47 gBrowser.selectedTab = gBrowser.tabs[0]; |
|
48 |
|
49 executeSoon(function () { |
|
50 openMoveToGroupPopup(); |
|
51 is(tvMenuPopup.firstChild.getAttribute("label"), "group2", "menuItem is present"); |
|
52 hideMoveToGroupPopup(); |
|
53 |
|
54 closeGroupItem(groupItem, function () { |
|
55 openMoveToGroupPopup(); |
|
56 is(tvMenuPopup.firstChild.tagName, "menuseparator", "menuItem is not present"); |
|
57 hideMoveToGroupPopup(); |
|
58 |
|
59 assertValidPrerequisites(false); |
|
60 finish(); |
|
61 }); |
|
62 }); |
|
63 }); |
|
64 }); |
|
65 } |