1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug590606.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,81 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +let originalTab; 1.8 +let newTabOne; 1.9 +let groupItemTwoId; 1.10 + 1.11 +function test() { 1.12 + waitForExplicitFinish(); 1.13 + 1.14 + originalTab = gBrowser.visibleTabs[0]; 1.15 + // add a tab to the existing group. 1.16 + newTabOne = gBrowser.addTab(); 1.17 + 1.18 + registerCleanupFunction(function() { 1.19 + while (gBrowser.tabs[1]) 1.20 + gBrowser.removeTab(gBrowser.tabs[1]); 1.21 + hideTabView(); 1.22 + }); 1.23 + 1.24 + showTabView(function() { 1.25 + let contentWindow = TabView.getContentWindow(); 1.26 + 1.27 + registerCleanupFunction(function() { 1.28 + let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId); 1.29 + if (groupItem) 1.30 + closeGroupItem(groupItem); 1.31 + }); 1.32 + 1.33 + is(contentWindow.GroupItems.groupItems.length, 1, 1.34 + "There is one group item on startup"); 1.35 + let groupItemOne = contentWindow.GroupItems.groupItems[0]; 1.36 + is(groupItemOne.getChildren().length, 2, 1.37 + "There should be two tab items in that group."); 1.38 + is(gBrowser.selectedTab, groupItemOne.getChild(0).tab, 1.39 + "The currently selected tab should be the first tab in the groupItemOne"); 1.40 + 1.41 + // create another group with a tab. 1.42 + let groupItemTwo = createGroupItemWithBlankTabs(window, 300, 300, 200, 1); 1.43 + groupItemTwoId = groupItemTwoId; 1.44 + hideTabView(function() { 1.45 + // start the test 1.46 + testGroupSwitch(contentWindow, groupItemOne, groupItemTwo); 1.47 + }); 1.48 + }); 1.49 +} 1.50 + 1.51 +function testGroupSwitch(contentWindow, groupItemOne, groupItemTwo) { 1.52 + is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab, 1.53 + "The currently selected tab should be the only tab in the groupItemTwo"); 1.54 + 1.55 + // switch to groupItemOne 1.56 + let tabItem = contentWindow.GroupItems.getNextGroupItemTab(false); 1.57 + if (tabItem) 1.58 + gBrowser.selectedTab = tabItem.tab; 1.59 + is(gBrowser.selectedTab, groupItemOne.getChild(0).tab, 1.60 + "The currently selected tab should be the first tab in the groupItemOne"); 1.61 + 1.62 + // switch to the second tab in groupItemOne 1.63 + gBrowser.selectedTab = groupItemOne.getChild(1).tab; 1.64 + 1.65 + // switch to groupItemTwo 1.66 + tabItem = contentWindow.GroupItems.getNextGroupItemTab(false); 1.67 + if (tabItem) 1.68 + gBrowser.selectedTab = tabItem.tab; 1.69 + is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab, 1.70 + "The currently selected tab should be the only tab in the groupItemTwo"); 1.71 + 1.72 + // switch to groupItemOne 1.73 + tabItem = contentWindow.GroupItems.getNextGroupItemTab(false); 1.74 + if (tabItem) 1.75 + gBrowser.selectedTab = tabItem.tab; 1.76 + is(gBrowser.selectedTab, groupItemOne.getChild(1).tab, 1.77 + "The currently selected tab should be the second tab in the groupItemOne"); 1.78 + 1.79 + // cleanup. 1.80 + gBrowser.removeTab(groupItemTwo.getChild(0).tab); 1.81 + gBrowser.removeTab(newTabOne); 1.82 + 1.83 + finish(); 1.84 +}