2011-02-27 17:36:36 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
2010-12-15 19:43:25 -08:00
|
|
|
|
2011-06-22 20:42:50 -07:00
|
|
|
let contentWindow;
|
|
|
|
let groupItemTwoId;
|
|
|
|
|
2010-12-15 19:43:25 -08:00
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
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
|
|
|
});
|
|
|
|
gBrowser.loadOneTab("about:blank", { inBackground: true });
|
|
|
|
showTabView(setup);
|
2010-12-15 19:43:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function setup() {
|
2011-06-22 20:42:50 -07:00
|
|
|
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-12-15 19:43:25 -08:00
|
|
|
|
2011-06-22 20:42:50 -07:00
|
|
|
let contentWindow = TabView.getContentWindow();
|
2010-12-15 19:43:25 -08:00
|
|
|
is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
|
|
|
|
|
|
|
|
let groupItemOne = contentWindow.GroupItems.groupItems[0];
|
2011-06-22 20:42:50 -07:00
|
|
|
is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items");
|
2010-12-15 19:43:25 -08:00
|
|
|
|
2011-06-22 20:42:50 -07:00
|
|
|
let groupItemTwo = createGroupItemWithBlankTabs(window, 250, 250, 40, 1);
|
|
|
|
groupItemTwoId = groupItemTwo.id;
|
|
|
|
testGroups(groupItemOne, groupItemTwo, contentWindow);
|
2010-12-15 19:43:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function testGroups(groupItemOne, groupItemTwo, contentWindow) {
|
|
|
|
// check active tab and group
|
|
|
|
is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo,
|
|
|
|
"The group two is the active group");
|
|
|
|
is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(0),
|
|
|
|
"The first tab item in group two is active");
|
|
|
|
|
|
|
|
let tabItem = groupItemOne.getChild(1);
|
2011-07-14 10:54:25 -07:00
|
|
|
tabItem.addSubscriber("tabRemoved", function onTabRemoved() {
|
|
|
|
tabItem.removeSubscriber("tabRemoved", onTabRemoved);
|
2010-12-15 19:43:25 -08:00
|
|
|
|
|
|
|
is(groupItemOne.getChildren().length, 1,
|
|
|
|
"The num of childen in group one is 1");
|
|
|
|
|
|
|
|
// check active group and active tab
|
|
|
|
is(contentWindow.GroupItems.getActiveGroupItem(), groupItemOne,
|
|
|
|
"The group one is the active group");
|
|
|
|
is(contentWindow.UI.getActiveTab(), groupItemOne.getChild(0),
|
|
|
|
"The first tab item in group one is active");
|
|
|
|
|
2011-06-22 20:42:50 -07:00
|
|
|
whenTabViewIsHidden(function() {
|
2010-12-15 19:43:25 -08:00
|
|
|
is(groupItemOne.getChildren().length, 2,
|
|
|
|
"The num of childen in group one is 2");
|
|
|
|
|
|
|
|
// clean up and finish
|
2011-06-22 20:42:50 -07:00
|
|
|
closeGroupItem(groupItemTwo, function() {
|
2010-12-15 19:43:25 -08:00
|
|
|
gBrowser.removeTab(groupItemOne.getChild(1).tab);
|
|
|
|
is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
|
|
|
|
is(groupItemOne.getChildren().length, 1,
|
|
|
|
"The num of childen in group one is 1");
|
|
|
|
is(gBrowser.tabs.length, 1, "Has only one tab");
|
|
|
|
|
|
|
|
finish();
|
|
|
|
});
|
2011-06-22 20:42:50 -07:00
|
|
|
});
|
2010-12-15 19:43:25 -08:00
|
|
|
EventUtils.synthesizeKey("t", { accelKey: true });
|
|
|
|
});
|
|
|
|
// close a tab item in group one
|
2012-03-19 20:38:58 -07:00
|
|
|
EventUtils.synthesizeMouseAtCenter(tabItem.$close[0], {}, contentWindow);
|
2010-12-15 19:43:25 -08:00
|
|
|
}
|