Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | let contentWindow; |
michael@0 | 5 | let appTab; |
michael@0 | 6 | let originalTab; |
michael@0 | 7 | let exitButton; |
michael@0 | 8 | |
michael@0 | 9 | // ---------- |
michael@0 | 10 | function test() { |
michael@0 | 11 | waitForExplicitFinish(); |
michael@0 | 12 | |
michael@0 | 13 | window.addEventListener("tabviewshown", onTabViewLoadedAndShown, false); |
michael@0 | 14 | TabView.toggle(); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | // ---------- |
michael@0 | 18 | function onTabViewLoadedAndShown() { |
michael@0 | 19 | window.removeEventListener("tabviewshown", onTabViewLoadedAndShown, false); |
michael@0 | 20 | ok(TabView.isVisible(), "Tab View is visible"); |
michael@0 | 21 | |
michael@0 | 22 | contentWindow = document.getElementById("tab-view").contentWindow; |
michael@0 | 23 | |
michael@0 | 24 | // establish initial state |
michael@0 | 25 | is(contentWindow.GroupItems.groupItems.length, 1, |
michael@0 | 26 | "we start with one group (the default)"); |
michael@0 | 27 | is(gBrowser.tabs.length, 1, "we start with one tab"); |
michael@0 | 28 | originalTab = gBrowser.tabs[0]; |
michael@0 | 29 | ok(!originalTab.pinned, "the original tab is not an app tab"); |
michael@0 | 30 | |
michael@0 | 31 | // create an app tab |
michael@0 | 32 | appTab = gBrowser.loadOneTab("about:blank"); |
michael@0 | 33 | is(gBrowser.tabs.length, 2, "we now have two tabs"); |
michael@0 | 34 | gBrowser.pinTab(appTab); |
michael@0 | 35 | |
michael@0 | 36 | // verify that the normal tab is selected |
michael@0 | 37 | ok(originalTab.selected, "the normal tab is selected"); |
michael@0 | 38 | |
michael@0 | 39 | // hit the exit button for the first time |
michael@0 | 40 | exitButton = contentWindow.document.getElementById("exit-button"); |
michael@0 | 41 | ok(exitButton, "Exit button exists"); |
michael@0 | 42 | |
michael@0 | 43 | window.addEventListener("tabviewhidden", onTabViewHiddenForNormalTab, false); |
michael@0 | 44 | EventUtils.sendMouseEvent({ type: "click" }, exitButton, contentWindow); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | // ---------- |
michael@0 | 48 | function onTabViewHiddenForNormalTab() { |
michael@0 | 49 | window.removeEventListener("tabviewhidden", onTabViewHiddenForNormalTab, false); |
michael@0 | 50 | ok(!TabView.isVisible(), "Tab View is not visible"); |
michael@0 | 51 | |
michael@0 | 52 | // verify that the normal tab is still selected |
michael@0 | 53 | ok(originalTab.selected, "the normal tab is still selected"); |
michael@0 | 54 | |
michael@0 | 55 | // select the app tab |
michael@0 | 56 | gBrowser.selectedTab = appTab; |
michael@0 | 57 | ok(appTab.selected, "the app tab is now selected"); |
michael@0 | 58 | |
michael@0 | 59 | // go back to tabview |
michael@0 | 60 | window.addEventListener("tabviewshown", onTabViewShown, false); |
michael@0 | 61 | TabView.toggle(); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | // ---------- |
michael@0 | 65 | function onTabViewShown() { |
michael@0 | 66 | window.removeEventListener("tabviewshown", onTabViewShown, false); |
michael@0 | 67 | ok(TabView.isVisible(), "Tab View is visible"); |
michael@0 | 68 | |
michael@0 | 69 | // hit the exit button again |
michael@0 | 70 | window.addEventListener("tabviewhidden", onTabViewHiddenForAppTab, false); |
michael@0 | 71 | EventUtils.sendMouseEvent({ type: "click" }, exitButton, contentWindow); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | // ---------- |
michael@0 | 75 | function onTabViewHiddenForAppTab() { |
michael@0 | 76 | window.removeEventListener("tabviewhidden", onTabViewHiddenForAppTab, false); |
michael@0 | 77 | ok(!TabView.isVisible(), "Tab View is not visible"); |
michael@0 | 78 | |
michael@0 | 79 | // verify that the app tab is still selected |
michael@0 | 80 | ok(appTab.selected, "the app tab is still selected"); |
michael@0 | 81 | |
michael@0 | 82 | // clean up |
michael@0 | 83 | gBrowser.selectedTab = originalTab; |
michael@0 | 84 | gBrowser.removeTab(appTab); |
michael@0 | 85 | |
michael@0 | 86 | is(gBrowser.tabs.length, 1, "we finish with one tab"); |
michael@0 | 87 | ok(originalTab.selected, |
michael@0 | 88 | "we finish with the normal tab selected"); |
michael@0 | 89 | ok(!TabView.isVisible(), "we finish with Tab View not visible"); |
michael@0 | 90 | |
michael@0 | 91 | finish(); |
michael@0 | 92 | } |