2011-02-27 17:36:36 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
2010-09-30 03:08:28 -07:00
|
|
|
|
|
|
|
let originalTab;
|
|
|
|
let newTabOne;
|
2011-06-22 20:42:50 -07:00
|
|
|
let groupItemTwoId;
|
2010-09-30 03:08:28 -07:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
originalTab = gBrowser.visibleTabs[0];
|
|
|
|
// add a tab to the existing group.
|
|
|
|
newTabOne = gBrowser.addTab();
|
|
|
|
|
2011-06-22 20:42:50 -07:00
|
|
|
registerCleanupFunction(function() {
|
|
|
|
while (gBrowser.tabs[1])
|
|
|
|
gBrowser.removeTab(gBrowser.tabs[1]);
|
2011-08-09 10:13:54 -07:00
|
|
|
hideTabView();
|
2011-06-22 20:42:50 -07:00
|
|
|
});
|
2010-09-30 03:08:28 -07:00
|
|
|
|
2011-06-22 20:42:50 -07:00
|
|
|
showTabView(function() {
|
|
|
|
let contentWindow = TabView.getContentWindow();
|
|
|
|
|
|
|
|
registerCleanupFunction(function() {
|
|
|
|
let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
|
|
|
|
if (groupItem)
|
2011-08-09 10:13:54 -07:00
|
|
|
closeGroupItem(groupItem);
|
2011-06-22 20:42:50 -07:00
|
|
|
});
|
2010-09-30 03:08:28 -07:00
|
|
|
|
|
|
|
is(contentWindow.GroupItems.groupItems.length, 1,
|
|
|
|
"There is one group item on startup");
|
|
|
|
let groupItemOne = contentWindow.GroupItems.groupItems[0];
|
|
|
|
is(groupItemOne.getChildren().length, 2,
|
|
|
|
"There should be two tab items in that group.");
|
|
|
|
is(gBrowser.selectedTab, groupItemOne.getChild(0).tab,
|
|
|
|
"The currently selected tab should be the first tab in the groupItemOne");
|
|
|
|
|
|
|
|
// create another group with a tab.
|
2011-06-22 20:42:50 -07:00
|
|
|
let groupItemTwo = createGroupItemWithBlankTabs(window, 300, 300, 200, 1);
|
|
|
|
groupItemTwoId = groupItemTwoId;
|
|
|
|
hideTabView(function() {
|
2010-09-30 03:08:28 -07:00
|
|
|
// start the test
|
|
|
|
testGroupSwitch(contentWindow, groupItemOne, groupItemTwo);
|
2011-06-22 20:42:50 -07:00
|
|
|
});
|
|
|
|
});
|
2010-09-30 03:08:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function testGroupSwitch(contentWindow, groupItemOne, groupItemTwo) {
|
|
|
|
is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab,
|
|
|
|
"The currently selected tab should be the only tab in the groupItemTwo");
|
|
|
|
|
|
|
|
// switch to groupItemOne
|
2011-01-18 04:25:59 -08:00
|
|
|
let tabItem = contentWindow.GroupItems.getNextGroupItemTab(false);
|
2010-09-30 03:08:28 -07:00
|
|
|
if (tabItem)
|
|
|
|
gBrowser.selectedTab = tabItem.tab;
|
|
|
|
is(gBrowser.selectedTab, groupItemOne.getChild(0).tab,
|
|
|
|
"The currently selected tab should be the first tab in the groupItemOne");
|
|
|
|
|
|
|
|
// switch to the second tab in groupItemOne
|
|
|
|
gBrowser.selectedTab = groupItemOne.getChild(1).tab;
|
|
|
|
|
|
|
|
// switch to groupItemTwo
|
|
|
|
tabItem = contentWindow.GroupItems.getNextGroupItemTab(false);
|
|
|
|
if (tabItem)
|
|
|
|
gBrowser.selectedTab = tabItem.tab;
|
|
|
|
is(gBrowser.selectedTab, groupItemTwo.getChild(0).tab,
|
|
|
|
"The currently selected tab should be the only tab in the groupItemTwo");
|
|
|
|
|
|
|
|
// switch to groupItemOne
|
|
|
|
tabItem = contentWindow.GroupItems.getNextGroupItemTab(false);
|
|
|
|
if (tabItem)
|
|
|
|
gBrowser.selectedTab = tabItem.tab;
|
|
|
|
is(gBrowser.selectedTab, groupItemOne.getChild(1).tab,
|
|
|
|
"The currently selected tab should be the second tab in the groupItemOne");
|
|
|
|
|
|
|
|
// cleanup.
|
2011-07-03 17:11:40 -07:00
|
|
|
gBrowser.removeTab(groupItemTwo.getChild(0).tab);
|
2010-09-30 03:08:28 -07:00
|
|
|
gBrowser.removeTab(newTabOne);
|
2011-07-03 17:11:40 -07:00
|
|
|
|
|
|
|
finish();
|
2010-09-30 03:08:28 -07:00
|
|
|
}
|