michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let contentWindow; michael@0: let groupItemTwoId; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: registerCleanupFunction(function() { michael@0: while (gBrowser.tabs[1]) michael@0: gBrowser.removeTab(gBrowser.tabs[1]); michael@0: hideTabView(); michael@0: }); michael@0: gBrowser.loadOneTab("about:blank", { inBackground: true }); michael@0: showTabView(setup); michael@0: } michael@0: michael@0: function setup() { michael@0: registerCleanupFunction(function() { michael@0: let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId); michael@0: if (groupItem) michael@0: closeGroupItem(groupItem); michael@0: }); michael@0: michael@0: let contentWindow = TabView.getContentWindow(); michael@0: is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); michael@0: michael@0: let groupItemOne = contentWindow.GroupItems.groupItems[0]; michael@0: is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items"); michael@0: michael@0: let groupItemTwo = createGroupItemWithBlankTabs(window, 250, 250, 40, 1); michael@0: groupItemTwoId = groupItemTwo.id; michael@0: testGroups(groupItemOne, groupItemTwo, contentWindow); michael@0: } michael@0: michael@0: function testGroups(groupItemOne, groupItemTwo, contentWindow) { michael@0: // check active tab and group michael@0: is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo, michael@0: "The group two is the active group"); michael@0: is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(0), michael@0: "The first tab item in group two is active"); michael@0: michael@0: let tabItem = groupItemOne.getChild(1); michael@0: tabItem.addSubscriber("tabRemoved", function onTabRemoved() { michael@0: tabItem.removeSubscriber("tabRemoved", onTabRemoved); michael@0: michael@0: is(groupItemOne.getChildren().length, 1, michael@0: "The num of childen in group one is 1"); michael@0: michael@0: // check active group and active tab michael@0: is(contentWindow.GroupItems.getActiveGroupItem(), groupItemOne, michael@0: "The group one is the active group"); michael@0: is(contentWindow.UI.getActiveTab(), groupItemOne.getChild(0), michael@0: "The first tab item in group one is active"); michael@0: michael@0: whenTabViewIsHidden(function() { michael@0: is(groupItemOne.getChildren().length, 2, michael@0: "The num of childen in group one is 2"); michael@0: michael@0: // clean up and finish michael@0: closeGroupItem(groupItemTwo, function() { michael@0: gBrowser.removeTab(groupItemOne.getChild(1).tab); michael@0: is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group"); michael@0: is(groupItemOne.getChildren().length, 1, michael@0: "The num of childen in group one is 1"); michael@0: is(gBrowser.tabs.length, 1, "Has only one tab"); michael@0: michael@0: finish(); michael@0: }); michael@0: }); michael@0: EventUtils.synthesizeKey("t", { accelKey: true }); michael@0: }); michael@0: // close a tab item in group one michael@0: EventUtils.synthesizeMouseAtCenter(tabItem.$close[0], {}, contentWindow); michael@0: }