michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let originalTab; michael@0: let newTabOne; michael@0: let groupItemTwoId; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: originalTab = gBrowser.visibleTabs[0]; michael@0: // add a tab to the existing group. michael@0: newTabOne = gBrowser.addTab(); michael@0: michael@0: registerCleanupFunction(function() { michael@0: while (gBrowser.tabs[1]) michael@0: gBrowser.removeTab(gBrowser.tabs[1]); michael@0: hideTabView(); michael@0: }); michael@0: michael@0: showTabView(function() { michael@0: let contentWindow = TabView.getContentWindow(); michael@0: michael@0: registerCleanupFunction(function() { michael@0: let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId); michael@0: if (groupItem) michael@0: closeGroupItem(groupItem); michael@0: }); michael@0: michael@0: is(contentWindow.GroupItems.groupItems.length, 1, michael@0: "There is one group item on startup"); michael@0: let groupItemOne = contentWindow.GroupItems.groupItems[0]; michael@0: is(groupItemOne.getChildren().length, 2, michael@0: "There should be two tab items in that group."); michael@0: is(gBrowser.selectedTab, groupItemOne.getChild(0).tab, michael@0: "The currently selected tab should be the first tab in the groupItemOne"); michael@0: michael@0: // create another group with a tab. michael@0: let groupItemTwo = createGroupItemWithBlankTabs(window, 300, 300, 200, 1); michael@0: groupItemTwoId = groupItemTwoId; michael@0: hideTabView(function() { michael@0: // start the test michael@0: testGroupSwitch(contentWindow, groupItemOne, groupItemTwo); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function testGroupSwitch(contentWindow, groupItemOne, groupItemTwo) { michael@0: is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab, michael@0: "The currently selected tab should be the only tab in the groupItemTwo"); michael@0: michael@0: // switch to groupItemOne michael@0: let tabItem = contentWindow.GroupItems.getNextGroupItemTab(false); michael@0: if (tabItem) michael@0: gBrowser.selectedTab = tabItem.tab; michael@0: is(gBrowser.selectedTab, groupItemOne.getChild(0).tab, michael@0: "The currently selected tab should be the first tab in the groupItemOne"); michael@0: michael@0: // switch to the second tab in groupItemOne michael@0: gBrowser.selectedTab = groupItemOne.getChild(1).tab; michael@0: michael@0: // switch to groupItemTwo michael@0: tabItem = contentWindow.GroupItems.getNextGroupItemTab(false); michael@0: if (tabItem) michael@0: gBrowser.selectedTab = tabItem.tab; michael@0: is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab, michael@0: "The currently selected tab should be the only tab in the groupItemTwo"); michael@0: michael@0: // switch to groupItemOne michael@0: tabItem = contentWindow.GroupItems.getNextGroupItemTab(false); michael@0: if (tabItem) michael@0: gBrowser.selectedTab = tabItem.tab; michael@0: is(gBrowser.selectedTab, groupItemOne.getChild(1).tab, michael@0: "The currently selected tab should be the second tab in the groupItemOne"); michael@0: michael@0: // cleanup. michael@0: gBrowser.removeTab(groupItemTwo.getChild(0).tab); michael@0: gBrowser.removeTab(newTabOne); michael@0: michael@0: finish(); michael@0: }