1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug608405.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 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 + let cw; 1.9 + 1.10 + let createGroupItem = function () { 1.11 + let bounds = new cw.Rect(20, 20, 200, 200); 1.12 + let groupItem = new cw.GroupItem([], {bounds: bounds, immediately: true}); 1.13 + 1.14 + cw.UI.setActive(groupItem); 1.15 + gBrowser.loadOneTab('about:blank', {inBackground: true}); 1.16 + 1.17 + return groupItem; 1.18 + } 1.19 + 1.20 + let finishTest = function () { 1.21 + ok(!TabView.isVisible(), 'cleanup: tabview is hidden'); 1.22 + is(gBrowser.tabs.length, 1, 'cleanup: there is one tab, only'); 1.23 + is(cw.GroupItems.groupItems.length, 1, 'cleanup: there is one group, only'); 1.24 + 1.25 + finish(); 1.26 + } 1.27 + 1.28 + let testAddChildFromAnotherGroup = function () { 1.29 + let sourceGroup = cw.GroupItems.groupItems[0]; 1.30 + let targetGroup = createGroupItem(); 1.31 + 1.32 + afterAllTabsLoaded(function () { 1.33 + // check setup 1.34 + is(sourceGroup.getChildren().length, 1, 'setup: source group has one child'); 1.35 + is(targetGroup.getChildren().length, 1, 'setup: target group has one child'); 1.36 + 1.37 + let tabItem = sourceGroup.getChild(0); 1.38 + targetGroup.add(tabItem); 1.39 + 1.40 + // check state after adding tabItem to targetGroup 1.41 + is(tabItem.parent, targetGroup, 'tabItem changed groups'); 1.42 + is(cw.GroupItems.groupItems.length, 1, 'source group was closed automatically'); 1.43 + is(targetGroup.getChildren().length, 2, 'target group has now two children'); 1.44 + 1.45 + // cleanup and finish 1.46 + targetGroup.getChild(0).close(); 1.47 + hideTabView(finishTest); 1.48 + }); 1.49 + } 1.50 + 1.51 + waitForExplicitFinish(); 1.52 + 1.53 + showTabView(function () { 1.54 + cw = TabView.getContentWindow(); 1.55 + testAddChildFromAnotherGroup(); 1.56 + }); 1.57 +}