1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug685692.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 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 + waitForExplicitFinish(); 1.9 + 1.10 + newWindowWithTabView(win => { 1.11 + win.gBrowser.addTab("http://example.com/"); 1.12 + win.gBrowser.addTab("http://example.com/"); 1.13 + 1.14 + afterAllTabsLoaded(function() { 1.15 + let cw = win.TabView.getContentWindow(); 1.16 + 1.17 + let groupItemOne = cw.GroupItems.groupItems[0]; 1.18 + is(groupItemOne.getChildren().length, 3, "The number of tabs in group one is 3"); 1.19 + 1.20 + // create a group with a blank tab 1.21 + let groupItemTwo = createGroupItemWithBlankTabs(win, 400, 400, 40, 1); 1.22 + is(groupItemTwo.getChildren().length, 1, "The number of tabs in group two is 1"); 1.23 + 1.24 + cw.UI.setActive(groupItemOne); 1.25 + 1.26 + moveTabToAnotherGroup(win, groupItemOne.getChild(2).tab, groupItemOne, groupItemTwo, function() { 1.27 + moveTabToAnotherGroup(win, groupItemOne.getChild(1).tab, groupItemOne, groupItemTwo, function() { 1.28 + groupItemOne.close(); 1.29 + promiseWindowClosed(win).then(finish); 1.30 + }); 1.31 + }); 1.32 + }); 1.33 + }); 1.34 +} 1.35 + 1.36 +function moveTabToAnotherGroup(win, targetTab, groupItemOne, groupItemTwo, callback) { 1.37 + hideTabView(function() { 1.38 + let tabCountInGroupItemOne = groupItemOne.getChildren().length; 1.39 + let tabCountInGroupItemTwo = groupItemTwo.getChildren().length; 1.40 + 1.41 + win.TabView.moveTabTo(targetTab, groupItemTwo.id); 1.42 + 1.43 + showTabView(function() { 1.44 + is(groupItemOne.getChildren().length, --tabCountInGroupItemOne, "The number of tab items in group one is decreased"); 1.45 + is(groupItemTwo.getChildren().length, ++tabCountInGroupItemTwo, "The number of tab items in group two is increased"); 1.46 + is(groupItemTwo.getChild(tabCountInGroupItemTwo-1).tab, targetTab, "The last tab is the moved tab"); 1.47 + 1.48 + callback(); 1.49 + }, win); 1.50 + }, win); 1.51 +}