1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug588265.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +let contentWindow; 1.8 +let groupItemTwoId; 1.9 + 1.10 +function test() { 1.11 + waitForExplicitFinish(); 1.12 + 1.13 + registerCleanupFunction(function() { 1.14 + while (gBrowser.tabs[1]) 1.15 + gBrowser.removeTab(gBrowser.tabs[1]); 1.16 + hideTabView(); 1.17 + }); 1.18 + gBrowser.loadOneTab("about:blank", { inBackground: true }); 1.19 + showTabView(setup); 1.20 +} 1.21 + 1.22 +function setup() { 1.23 + registerCleanupFunction(function() { 1.24 + let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId); 1.25 + if (groupItem) 1.26 + closeGroupItem(groupItem); 1.27 + }); 1.28 + 1.29 + let contentWindow = TabView.getContentWindow(); 1.30 + is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); 1.31 + 1.32 + let groupItemOne = contentWindow.GroupItems.groupItems[0]; 1.33 + is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items"); 1.34 + 1.35 + let groupItemTwo = createGroupItemWithBlankTabs(window, 250, 250, 40, 1); 1.36 + groupItemTwoId = groupItemTwo.id; 1.37 + testGroups(groupItemOne, groupItemTwo, contentWindow); 1.38 +} 1.39 + 1.40 +function testGroups(groupItemOne, groupItemTwo, contentWindow) { 1.41 + // check active tab and group 1.42 + is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo, 1.43 + "The group two is the active group"); 1.44 + is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(0), 1.45 + "The first tab item in group two is active"); 1.46 + 1.47 + let tabItem = groupItemOne.getChild(1); 1.48 + tabItem.addSubscriber("tabRemoved", function onTabRemoved() { 1.49 + tabItem.removeSubscriber("tabRemoved", onTabRemoved); 1.50 + 1.51 + is(groupItemOne.getChildren().length, 1, 1.52 + "The num of childen in group one is 1"); 1.53 + 1.54 + // check active group and active tab 1.55 + is(contentWindow.GroupItems.getActiveGroupItem(), groupItemOne, 1.56 + "The group one is the active group"); 1.57 + is(contentWindow.UI.getActiveTab(), groupItemOne.getChild(0), 1.58 + "The first tab item in group one is active"); 1.59 + 1.60 + whenTabViewIsHidden(function() { 1.61 + is(groupItemOne.getChildren().length, 2, 1.62 + "The num of childen in group one is 2"); 1.63 + 1.64 + // clean up and finish 1.65 + closeGroupItem(groupItemTwo, function() { 1.66 + gBrowser.removeTab(groupItemOne.getChild(1).tab); 1.67 + is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); 1.68 + is(groupItemOne.getChildren().length, 1, 1.69 + "The num of childen in group one is 1"); 1.70 + is(gBrowser.tabs.length, 1, "Has only one tab"); 1.71 + 1.72 + finish(); 1.73 + }); 1.74 + }); 1.75 + EventUtils.synthesizeKey("t", { accelKey: true }); 1.76 + }); 1.77 + // close a tab item in group one 1.78 + EventUtils.synthesizeMouseAtCenter(tabItem.$close[0], {}, contentWindow); 1.79 +}