michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: is(gBrowser.tabs.length, 1, "Only one tab exist"); michael@0: michael@0: let originalTab = gBrowser.tabs[0]; michael@0: michael@0: popup(originalTab); michael@0: ok(!document.getElementById("context_closeTab").disabled, "The 'Close tab' menu item is enabled"); michael@0: ok(document.getElementById("context_openTabInWindow").disabled, "The 'Move to New Window' menu item is disabled"); michael@0: michael@0: let newTabOne = gBrowser.addTab("about:blank", {skipAnimation: true}); michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: showTabView(function() { michael@0: registerCleanupFunction(function () { michael@0: while (gBrowser.tabs.length > 1) michael@0: gBrowser.removeTab(gBrowser.tabs[1]); michael@0: TabView.hide(); michael@0: }); michael@0: michael@0: let contentWindow = TabView.getContentWindow(); michael@0: is(contentWindow.GroupItems.groupItems.length, 1, "Has one group only"); michael@0: michael@0: let tabItems = contentWindow.GroupItems.groupItems[0].getChildren(); michael@0: ok(tabItems.length, 2, "There are two tabItems in this group"); michael@0: michael@0: whenTabViewIsHidden(function() { michael@0: popup(gBrowser.tabs[0]); michael@0: michael@0: ok(!document.getElementById("context_closeTab").disabled, "The 'Close tab' menu item is enabled"); michael@0: ok(!document.getElementById("context_openTabInWindow").disabled, "The 'Move to New Window' menu item is enabled"); michael@0: michael@0: let newTabTwo = gBrowser.selectedTab; michael@0: gBrowser.selectedTab = originalTab; michael@0: michael@0: gBrowser.removeTab(newTabOne); michael@0: gBrowser.removeTab(newTabTwo); michael@0: michael@0: finish(); michael@0: }); michael@0: let newGroup = contentWindow.GroupItems.newGroup(); michael@0: newGroup.newTab(); michael@0: }); michael@0: } michael@0: michael@0: function popup(tab) { michael@0: let menu = document.getElementById("tabContextMenu"); michael@0: var evt = new Event(""); michael@0: tab.dispatchEvent(evt); michael@0: menu.openPopup(tab, "end_after", 0, 0, true, false, evt); michael@0: TabContextMenu.updateContextMenu(menu); michael@0: is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab"); michael@0: menu.hidePopup(); michael@0: } michael@0: