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