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