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 | function test() { |
michael@0 | 5 | waitForExplicitFinish(); |
michael@0 | 6 | newWindowWithTabView(onTabViewWindowLoaded); |
michael@0 | 7 | } |
michael@0 | 8 | |
michael@0 | 9 | function onTabViewWindowLoaded(win) { |
michael@0 | 10 | ok(win.TabView.isVisible(), "Tab View is visible"); |
michael@0 | 11 | |
michael@0 | 12 | let contentWindow = win.document.getElementById("tab-view").contentWindow; |
michael@0 | 13 | let [originalTab] = win.gBrowser.visibleTabs; |
michael@0 | 14 | let originalGroup = contentWindow.GroupItems.getActiveGroupItem(); |
michael@0 | 15 | |
michael@0 | 16 | // open a group with a tab, and close either the group or the tab. |
michael@0 | 17 | function openAndClose(groupOrTab, callback) { |
michael@0 | 18 | // let's create a group with a tab. |
michael@0 | 19 | let group = new contentWindow.GroupItem([], { |
michael@0 | 20 | immediately: true, |
michael@0 | 21 | bounds: {left: 20, top: 20, width: 400, height: 400} |
michael@0 | 22 | }); |
michael@0 | 23 | contentWindow.UI.setActive(group); |
michael@0 | 24 | win.gBrowser.loadOneTab('about:blank', {inBackground: true}); |
michael@0 | 25 | |
michael@0 | 26 | is(group.getChildren().length, 1, "The group has one child now."); |
michael@0 | 27 | let tab = group.getChild(0); |
michael@0 | 28 | |
michael@0 | 29 | function check() { |
michael@0 | 30 | if (groupOrTab == 'group') { |
michael@0 | 31 | group.removeSubscriber("groupHidden", check); |
michael@0 | 32 | group.closeHidden(); |
michael@0 | 33 | } else |
michael@0 | 34 | tab.removeSubscriber("tabRemoved", check); |
michael@0 | 35 | |
michael@0 | 36 | is(contentWindow.GroupItems.getActiveGroupItem(), originalGroup, |
michael@0 | 37 | "The original group is active."); |
michael@0 | 38 | is(contentWindow.UI.getActiveTab(), originalTab._tabViewTabItem, |
michael@0 | 39 | "The original tab is active"); |
michael@0 | 40 | |
michael@0 | 41 | callback(); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | if (groupOrTab == 'group') { |
michael@0 | 45 | group.addSubscriber("groupHidden", check); |
michael@0 | 46 | group.closeAll(); |
michael@0 | 47 | } else { |
michael@0 | 48 | tab.addSubscriber("tabRemoved", check); |
michael@0 | 49 | tab.close(); |
michael@0 | 50 | } |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | // PHASE 1: create a group with a tab and close the group. |
michael@0 | 54 | openAndClose("group", function postPhase1() { |
michael@0 | 55 | // PHASE 2: create a group with a tab and close the tab. |
michael@0 | 56 | openAndClose("tab", function postPhase2() { |
michael@0 | 57 | win.close(); |
michael@0 | 58 | finish(); |
michael@0 | 59 | }); |
michael@0 | 60 | }); |
michael@0 | 61 | } |