1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug627736.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function test() { 1.8 + waitForExplicitFinish(); 1.9 + newWindowWithTabView(onTabViewWindowLoaded); 1.10 +} 1.11 + 1.12 +function onTabViewWindowLoaded(win) { 1.13 + ok(win.TabView.isVisible(), "Tab View is visible"); 1.14 + 1.15 + let contentWindow = win.document.getElementById("tab-view").contentWindow; 1.16 + let [originalTab] = win.gBrowser.visibleTabs; 1.17 + let originalGroup = contentWindow.GroupItems.getActiveGroupItem(); 1.18 + 1.19 + // open a group with a tab, and close either the group or the tab. 1.20 + function openAndClose(groupOrTab, callback) { 1.21 + // let's create a group with a tab. 1.22 + let group = new contentWindow.GroupItem([], { 1.23 + immediately: true, 1.24 + bounds: {left: 20, top: 20, width: 400, height: 400} 1.25 + }); 1.26 + contentWindow.UI.setActive(group); 1.27 + win.gBrowser.loadOneTab('about:blank', {inBackground: true}); 1.28 + 1.29 + is(group.getChildren().length, 1, "The group has one child now."); 1.30 + let tab = group.getChild(0); 1.31 + 1.32 + function check() { 1.33 + if (groupOrTab == 'group') { 1.34 + group.removeSubscriber("groupHidden", check); 1.35 + group.closeHidden(); 1.36 + } else 1.37 + tab.removeSubscriber("tabRemoved", check); 1.38 + 1.39 + is(contentWindow.GroupItems.getActiveGroupItem(), originalGroup, 1.40 + "The original group is active."); 1.41 + is(contentWindow.UI.getActiveTab(), originalTab._tabViewTabItem, 1.42 + "The original tab is active"); 1.43 + 1.44 + callback(); 1.45 + } 1.46 + 1.47 + if (groupOrTab == 'group') { 1.48 + group.addSubscriber("groupHidden", check); 1.49 + group.closeAll(); 1.50 + } else { 1.51 + tab.addSubscriber("tabRemoved", check); 1.52 + tab.close(); 1.53 + } 1.54 + } 1.55 + 1.56 + // PHASE 1: create a group with a tab and close the group. 1.57 + openAndClose("group", function postPhase1() { 1.58 + // PHASE 2: create a group with a tab and close the tab. 1.59 + openAndClose("tab", function postPhase2() { 1.60 + win.close(); 1.61 + finish(); 1.62 + }); 1.63 + }); 1.64 +}