1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug625195.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function test() { 1.8 + is(gBrowser.tabs.length, 1, "Only one tab exist"); 1.9 + 1.10 + let originalTab = gBrowser.tabs[0]; 1.11 + 1.12 + popup(originalTab); 1.13 + ok(!document.getElementById("context_closeTab").disabled, "The 'Close tab' menu item is enabled"); 1.14 + ok(document.getElementById("context_openTabInWindow").disabled, "The 'Move to New Window' menu item is disabled"); 1.15 + 1.16 + let newTabOne = gBrowser.addTab("about:blank", {skipAnimation: true}); 1.17 + 1.18 + waitForExplicitFinish(); 1.19 + 1.20 + showTabView(function() { 1.21 + registerCleanupFunction(function () { 1.22 + while (gBrowser.tabs.length > 1) 1.23 + gBrowser.removeTab(gBrowser.tabs[1]); 1.24 + TabView.hide(); 1.25 + }); 1.26 + 1.27 + let contentWindow = TabView.getContentWindow(); 1.28 + is(contentWindow.GroupItems.groupItems.length, 1, "Has one group only"); 1.29 + 1.30 + let tabItems = contentWindow.GroupItems.groupItems[0].getChildren(); 1.31 + ok(tabItems.length, 2, "There are two tabItems in this group"); 1.32 + 1.33 + whenTabViewIsHidden(function() { 1.34 + popup(gBrowser.tabs[0]); 1.35 + 1.36 + ok(!document.getElementById("context_closeTab").disabled, "The 'Close tab' menu item is enabled"); 1.37 + ok(!document.getElementById("context_openTabInWindow").disabled, "The 'Move to New Window' menu item is enabled"); 1.38 + 1.39 + let newTabTwo = gBrowser.selectedTab; 1.40 + gBrowser.selectedTab = originalTab; 1.41 + 1.42 + gBrowser.removeTab(newTabOne); 1.43 + gBrowser.removeTab(newTabTwo); 1.44 + 1.45 + finish(); 1.46 + }); 1.47 + let newGroup = contentWindow.GroupItems.newGroup(); 1.48 + newGroup.newTab(); 1.49 + }); 1.50 +} 1.51 + 1.52 +function popup(tab) { 1.53 + let menu = document.getElementById("tabContextMenu"); 1.54 + var evt = new Event(""); 1.55 + tab.dispatchEvent(evt); 1.56 + menu.openPopup(tab, "end_after", 0, 0, true, false, evt); 1.57 + TabContextMenu.updateContextMenu(menu); 1.58 + is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab"); 1.59 + menu.hidePopup(); 1.60 +} 1.61 +