|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function test() { |
|
5 is(gBrowser.tabs.length, 1, "Only one tab exist"); |
|
6 |
|
7 let originalTab = gBrowser.tabs[0]; |
|
8 |
|
9 popup(originalTab); |
|
10 ok(!document.getElementById("context_closeTab").disabled, "The 'Close tab' menu item is enabled"); |
|
11 ok(document.getElementById("context_openTabInWindow").disabled, "The 'Move to New Window' menu item is disabled"); |
|
12 |
|
13 let newTabOne = gBrowser.addTab("about:blank", {skipAnimation: true}); |
|
14 |
|
15 waitForExplicitFinish(); |
|
16 |
|
17 showTabView(function() { |
|
18 registerCleanupFunction(function () { |
|
19 while (gBrowser.tabs.length > 1) |
|
20 gBrowser.removeTab(gBrowser.tabs[1]); |
|
21 TabView.hide(); |
|
22 }); |
|
23 |
|
24 let contentWindow = TabView.getContentWindow(); |
|
25 is(contentWindow.GroupItems.groupItems.length, 1, "Has one group only"); |
|
26 |
|
27 let tabItems = contentWindow.GroupItems.groupItems[0].getChildren(); |
|
28 ok(tabItems.length, 2, "There are two tabItems in this group"); |
|
29 |
|
30 whenTabViewIsHidden(function() { |
|
31 popup(gBrowser.tabs[0]); |
|
32 |
|
33 ok(!document.getElementById("context_closeTab").disabled, "The 'Close tab' menu item is enabled"); |
|
34 ok(!document.getElementById("context_openTabInWindow").disabled, "The 'Move to New Window' menu item is enabled"); |
|
35 |
|
36 let newTabTwo = gBrowser.selectedTab; |
|
37 gBrowser.selectedTab = originalTab; |
|
38 |
|
39 gBrowser.removeTab(newTabOne); |
|
40 gBrowser.removeTab(newTabTwo); |
|
41 |
|
42 finish(); |
|
43 }); |
|
44 let newGroup = contentWindow.GroupItems.newGroup(); |
|
45 newGroup.newTab(); |
|
46 }); |
|
47 } |
|
48 |
|
49 function popup(tab) { |
|
50 let menu = document.getElementById("tabContextMenu"); |
|
51 var evt = new Event(""); |
|
52 tab.dispatchEvent(evt); |
|
53 menu.openPopup(tab, "end_after", 0, 0, true, false, evt); |
|
54 TabContextMenu.updateContextMenu(menu); |
|
55 is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab"); |
|
56 menu.hidePopup(); |
|
57 } |
|
58 |