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-10 07:51:08 -07:00
|
|
|
|
2010-09-24 16:22:35 -07:00
|
|
|
let contentWindow;
|
|
|
|
let appTab;
|
|
|
|
let originalTab;
|
|
|
|
let exitButton;
|
|
|
|
|
|
|
|
// ----------
|
2010-09-10 07:51:08 -07:00
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2010-09-24 16:22:35 -07:00
|
|
|
window.addEventListener("tabviewshown", onTabViewLoadedAndShown, false);
|
|
|
|
TabView.toggle();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
function onTabViewLoadedAndShown() {
|
|
|
|
window.removeEventListener("tabviewshown", onTabViewLoadedAndShown, false);
|
|
|
|
ok(TabView.isVisible(), "Tab View is visible");
|
|
|
|
|
|
|
|
contentWindow = document.getElementById("tab-view").contentWindow;
|
2010-09-10 07:51:08 -07:00
|
|
|
|
2010-09-24 16:22:35 -07:00
|
|
|
// establish initial state
|
|
|
|
is(contentWindow.GroupItems.groupItems.length, 1,
|
|
|
|
"we start with one group (the default)");
|
|
|
|
is(gBrowser.tabs.length, 1, "we start with one tab");
|
|
|
|
originalTab = gBrowser.tabs[0];
|
|
|
|
ok(!originalTab.pinned, "the original tab is not an app tab");
|
|
|
|
|
|
|
|
// create an app tab
|
|
|
|
appTab = gBrowser.loadOneTab("about:blank");
|
|
|
|
is(gBrowser.tabs.length, 2, "we now have two tabs");
|
|
|
|
gBrowser.pinTab(appTab);
|
|
|
|
|
|
|
|
// verify that the normal tab is selected
|
2012-12-24 08:08:22 -08:00
|
|
|
ok(originalTab.selected, "the normal tab is selected");
|
2010-09-24 16:22:35 -07:00
|
|
|
|
|
|
|
// hit the exit button for the first time
|
|
|
|
exitButton = contentWindow.document.getElementById("exit-button");
|
|
|
|
ok(exitButton, "Exit button exists");
|
|
|
|
|
|
|
|
window.addEventListener("tabviewhidden", onTabViewHiddenForNormalTab, false);
|
|
|
|
EventUtils.sendMouseEvent({ type: "click" }, exitButton, contentWindow);
|
|
|
|
}
|
2010-09-10 07:51:08 -07:00
|
|
|
|
2010-09-24 16:22:35 -07:00
|
|
|
// ----------
|
|
|
|
function onTabViewHiddenForNormalTab() {
|
|
|
|
window.removeEventListener("tabviewhidden", onTabViewHiddenForNormalTab, false);
|
|
|
|
ok(!TabView.isVisible(), "Tab View is not visible");
|
2010-09-10 07:51:08 -07:00
|
|
|
|
2010-09-24 16:22:35 -07:00
|
|
|
// verify that the normal tab is still selected
|
2012-12-24 08:08:22 -08:00
|
|
|
ok(originalTab.selected, "the normal tab is still selected");
|
2010-09-10 07:51:08 -07:00
|
|
|
|
2010-09-24 16:22:35 -07:00
|
|
|
// select the app tab
|
|
|
|
gBrowser.selectedTab = appTab;
|
2012-12-24 08:08:22 -08:00
|
|
|
ok(appTab.selected, "the app tab is now selected");
|
2010-09-10 07:51:08 -07:00
|
|
|
|
2010-09-24 16:22:35 -07:00
|
|
|
// go back to tabview
|
2010-09-10 07:51:08 -07:00
|
|
|
window.addEventListener("tabviewshown", onTabViewShown, false);
|
|
|
|
TabView.toggle();
|
|
|
|
}
|
2010-09-24 16:22:35 -07:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
function onTabViewShown() {
|
|
|
|
window.removeEventListener("tabviewshown", onTabViewShown, false);
|
|
|
|
ok(TabView.isVisible(), "Tab View is visible");
|
|
|
|
|
|
|
|
// hit the exit button again
|
|
|
|
window.addEventListener("tabviewhidden", onTabViewHiddenForAppTab, false);
|
|
|
|
EventUtils.sendMouseEvent({ type: "click" }, exitButton, contentWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
function onTabViewHiddenForAppTab() {
|
|
|
|
window.removeEventListener("tabviewhidden", onTabViewHiddenForAppTab, false);
|
|
|
|
ok(!TabView.isVisible(), "Tab View is not visible");
|
|
|
|
|
|
|
|
// verify that the app tab is still selected
|
2012-12-24 08:08:22 -08:00
|
|
|
ok(appTab.selected, "the app tab is still selected");
|
2010-09-24 16:22:35 -07:00
|
|
|
|
|
|
|
// clean up
|
2012-12-24 08:08:22 -08:00
|
|
|
gBrowser.selectedTab = originalTab;
|
2010-09-24 16:22:35 -07:00
|
|
|
gBrowser.removeTab(appTab);
|
|
|
|
|
|
|
|
is(gBrowser.tabs.length, 1, "we finish with one tab");
|
2012-12-24 08:08:22 -08:00
|
|
|
ok(originalTab.selected,
|
2010-09-24 16:22:35 -07:00
|
|
|
"we finish with the normal tab selected");
|
|
|
|
ok(!TabView.isVisible(), "we finish with Tab View not visible");
|
|
|
|
|
|
|
|
finish();
|
|
|
|
}
|