2011-02-27 17:36:36 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
2011-01-25 11:14:10 -08:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
newWindowWithTabView(onTabViewWindowLoaded);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onTabViewWindowLoaded(win) {
|
|
|
|
ok(win.TabView.isVisible(), "Tab View is visible");
|
|
|
|
|
|
|
|
let contentWindow = win.document.getElementById("tab-view").contentWindow;
|
|
|
|
let [originalTab] = win.gBrowser.visibleTabs;
|
|
|
|
let originalGroup = contentWindow.GroupItems.getActiveGroupItem();
|
|
|
|
|
|
|
|
// open a group with a tab, and close either the group or the tab.
|
|
|
|
function openAndClose(groupOrTab, callback) {
|
|
|
|
// let's create a group with a tab.
|
|
|
|
let group = new contentWindow.GroupItem([], {
|
|
|
|
immediately: true,
|
|
|
|
bounds: {left: 20, top: 20, width: 400, height: 400}
|
|
|
|
});
|
2011-04-22 13:05:11 -07:00
|
|
|
contentWindow.UI.setActive(group);
|
2011-01-25 11:14:10 -08:00
|
|
|
win.gBrowser.loadOneTab('about:blank', {inBackground: true});
|
|
|
|
|
|
|
|
is(group.getChildren().length, 1, "The group has one child now.");
|
|
|
|
let tab = group.getChild(0);
|
2011-07-03 17:11:40 -07:00
|
|
|
|
2011-06-17 05:07:59 -07:00
|
|
|
function check() {
|
|
|
|
if (groupOrTab == 'group') {
|
2011-07-14 10:54:25 -07:00
|
|
|
group.removeSubscriber("groupHidden", check);
|
2011-06-17 05:07:59 -07:00
|
|
|
group.closeHidden();
|
2011-07-03 17:11:40 -07:00
|
|
|
} else
|
2011-07-14 10:54:25 -07:00
|
|
|
tab.removeSubscriber("tabRemoved", check);
|
2011-07-03 17:11:40 -07:00
|
|
|
|
|
|
|
is(contentWindow.GroupItems.getActiveGroupItem(), originalGroup,
|
|
|
|
"The original group is active.");
|
|
|
|
is(contentWindow.UI.getActiveTab(), originalTab._tabViewTabItem,
|
|
|
|
"The original tab is active");
|
|
|
|
|
|
|
|
callback();
|
2011-06-17 05:07:59 -07:00
|
|
|
}
|
2011-01-25 11:14:10 -08:00
|
|
|
|
|
|
|
if (groupOrTab == 'group') {
|
2011-07-14 10:54:25 -07:00
|
|
|
group.addSubscriber("groupHidden", check);
|
2011-01-25 11:14:10 -08:00
|
|
|
group.closeAll();
|
|
|
|
} else {
|
2011-07-14 10:54:25 -07:00
|
|
|
tab.addSubscriber("tabRemoved", check);
|
2011-01-25 11:14:10 -08:00
|
|
|
tab.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PHASE 1: create a group with a tab and close the group.
|
|
|
|
openAndClose("group", function postPhase1() {
|
|
|
|
// PHASE 2: create a group with a tab and close the tab.
|
|
|
|
openAndClose("tab", function postPhase2() {
|
|
|
|
win.close();
|
|
|
|
finish();
|
|
|
|
});
|
|
|
|
});
|
2011-07-14 10:54:25 -07:00
|
|
|
}
|