michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let contentWindow; michael@0: let appTab; michael@0: let originalTab; michael@0: let exitButton; michael@0: michael@0: // ---------- michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: window.addEventListener("tabviewshown", onTabViewLoadedAndShown, false); michael@0: TabView.toggle(); michael@0: } michael@0: michael@0: // ---------- michael@0: function onTabViewLoadedAndShown() { michael@0: window.removeEventListener("tabviewshown", onTabViewLoadedAndShown, false); michael@0: ok(TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: contentWindow = document.getElementById("tab-view").contentWindow; michael@0: michael@0: // establish initial state michael@0: is(contentWindow.GroupItems.groupItems.length, 1, michael@0: "we start with one group (the default)"); michael@0: is(gBrowser.tabs.length, 1, "we start with one tab"); michael@0: originalTab = gBrowser.tabs[0]; michael@0: ok(!originalTab.pinned, "the original tab is not an app tab"); michael@0: michael@0: // create an app tab michael@0: appTab = gBrowser.loadOneTab("about:blank"); michael@0: is(gBrowser.tabs.length, 2, "we now have two tabs"); michael@0: gBrowser.pinTab(appTab); michael@0: michael@0: // verify that the normal tab is selected michael@0: ok(originalTab.selected, "the normal tab is selected"); michael@0: michael@0: // hit the exit button for the first time michael@0: exitButton = contentWindow.document.getElementById("exit-button"); michael@0: ok(exitButton, "Exit button exists"); michael@0: michael@0: window.addEventListener("tabviewhidden", onTabViewHiddenForNormalTab, false); michael@0: EventUtils.sendMouseEvent({ type: "click" }, exitButton, contentWindow); michael@0: } michael@0: michael@0: // ---------- michael@0: function onTabViewHiddenForNormalTab() { michael@0: window.removeEventListener("tabviewhidden", onTabViewHiddenForNormalTab, false); michael@0: ok(!TabView.isVisible(), "Tab View is not visible"); michael@0: michael@0: // verify that the normal tab is still selected michael@0: ok(originalTab.selected, "the normal tab is still selected"); michael@0: michael@0: // select the app tab michael@0: gBrowser.selectedTab = appTab; michael@0: ok(appTab.selected, "the app tab is now selected"); michael@0: michael@0: // go back to tabview michael@0: window.addEventListener("tabviewshown", onTabViewShown, false); michael@0: TabView.toggle(); michael@0: } michael@0: michael@0: // ---------- michael@0: function onTabViewShown() { michael@0: window.removeEventListener("tabviewshown", onTabViewShown, false); michael@0: ok(TabView.isVisible(), "Tab View is visible"); michael@0: michael@0: // hit the exit button again michael@0: window.addEventListener("tabviewhidden", onTabViewHiddenForAppTab, false); michael@0: EventUtils.sendMouseEvent({ type: "click" }, exitButton, contentWindow); michael@0: } michael@0: michael@0: // ---------- michael@0: function onTabViewHiddenForAppTab() { michael@0: window.removeEventListener("tabviewhidden", onTabViewHiddenForAppTab, false); michael@0: ok(!TabView.isVisible(), "Tab View is not visible"); michael@0: michael@0: // verify that the app tab is still selected michael@0: ok(appTab.selected, "the app tab is still selected"); michael@0: michael@0: // clean up michael@0: gBrowser.selectedTab = originalTab; michael@0: gBrowser.removeTab(appTab); michael@0: michael@0: is(gBrowser.tabs.length, 1, "we finish with one tab"); michael@0: ok(originalTab.selected, michael@0: "we finish with the normal tab selected"); michael@0: ok(!TabView.isVisible(), "we finish with Tab View not visible"); michael@0: michael@0: finish(); michael@0: }