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 bounds = new cw.Rect(20, 20, 200, 200); michael@0: let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true}); michael@0: michael@0: cw.UI.setActive(groupItem); michael@0: gBrowser.loadOneTab('about:blank', {inBackground: true}); michael@0: michael@0: return groupItem; michael@0: } michael@0: michael@0: let finishTest = function () { michael@0: ok(!TabView.isVisible(), 'cleanup: tabview is hidden'); michael@0: is(gBrowser.tabs.length, 1, 'cleanup: there is one tab, only'); michael@0: is(cw.GroupItems.groupItems.length, 1, 'cleanup: there is one group, only'); michael@0: michael@0: finish(); michael@0: } michael@0: michael@0: let testAddChildFromAnotherGroup = function () { michael@0: let sourceGroup = cw.GroupItems.groupItems[0]; michael@0: let targetGroup = createGroupItem(); michael@0: michael@0: afterAllTabsLoaded(function () { michael@0: // check setup michael@0: is(sourceGroup.getChildren().length, 1, 'setup: source group has one child'); michael@0: is(targetGroup.getChildren().length, 1, 'setup: target group has one child'); michael@0: michael@0: let tabItem = sourceGroup.getChild(0); michael@0: targetGroup.add(tabItem); michael@0: michael@0: // check state after adding tabItem to targetGroup michael@0: is(tabItem.parent, targetGroup, 'tabItem changed groups'); michael@0: is(cw.GroupItems.groupItems.length, 1, 'source group was closed automatically'); michael@0: is(targetGroup.getChildren().length, 2, 'target group has now two children'); michael@0: michael@0: // cleanup and finish michael@0: targetGroup.getChild(0).close(); michael@0: hideTabView(finishTest); michael@0: }); michael@0: } michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: showTabView(function () { michael@0: cw = TabView.getContentWindow(); michael@0: testAddChildFromAnotherGroup(); michael@0: }); michael@0: }