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: let cw; michael@0: michael@0: let createGroupItem = function () { michael@0: let groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1); michael@0: michael@0: let groupItemId = groupItem.id; michael@0: registerCleanupFunction(function() { michael@0: let groupItem = cw.GroupItems.groupItem(groupItemId); michael@0: if (groupItem) michael@0: groupItem.close(); michael@0: }); michael@0: michael@0: return groupItem; michael@0: } michael@0: michael@0: let testSingleGroupItem = function () { michael@0: let groupItem = cw.GroupItems.groupItems[0]; michael@0: is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is active"); michael@0: michael@0: let tabItem = groupItem.getChild(0); michael@0: is(cw.UI.getActiveTab(), tabItem, "tabItem is active"); michael@0: michael@0: hideGroupItem(groupItem, function () { michael@0: unhideGroupItem(groupItem, function () { michael@0: is(cw.GroupItems.getActiveGroupItem(), groupItem, "groupItem is still active"); michael@0: is(cw.UI.getActiveTab(), tabItem, "tabItem is still active"); michael@0: next(); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: let testTwoGroupItems = function () { michael@0: let groupItem = cw.GroupItems.groupItems[0]; michael@0: let tabItem = groupItem.getChild(0); michael@0: michael@0: let groupItem2 = createGroupItem(); michael@0: let tabItem2 = groupItem2.getChild(0); michael@0: michael@0: hideGroupItem(groupItem, function () { michael@0: is(cw.UI.getActiveTab(), tabItem2, "tabItem2 is active"); michael@0: unhideGroupItem(groupItem, function () { michael@0: cw.UI.setActive(tabItem); michael@0: closeGroupItem(groupItem2, next); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: let tests = [testSingleGroupItem, testTwoGroupItems]; michael@0: michael@0: let next = function () { michael@0: let test = tests.shift(); michael@0: if (test) michael@0: test(); michael@0: else michael@0: hideTabView(finishTest); michael@0: } michael@0: michael@0: let finishTest = function () { michael@0: is(cw.GroupItems.groupItems.length, 1, "there is one groupItem"); michael@0: is(gBrowser.tabs.length, 1, "there is one tab"); michael@0: ok(!TabView.isVisible(), "tabview is hidden"); michael@0: michael@0: finish(); michael@0: } michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: showTabView(function () { michael@0: registerCleanupFunction(function () TabView.hide()); michael@0: cw = TabView.getContentWindow(); michael@0: next(); michael@0: }); michael@0: }