browser/components/tabview/test/browser_tabview_bug685692.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:ea9258b54548
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 function test() {
5 waitForExplicitFinish();
6
7 newWindowWithTabView(win => {
8 win.gBrowser.addTab("http://example.com/");
9 win.gBrowser.addTab("http://example.com/");
10
11 afterAllTabsLoaded(function() {
12 let cw = win.TabView.getContentWindow();
13
14 let groupItemOne = cw.GroupItems.groupItems[0];
15 is(groupItemOne.getChildren().length, 3, "The number of tabs in group one is 3");
16
17 // create a group with a blank tab
18 let groupItemTwo = createGroupItemWithBlankTabs(win, 400, 400, 40, 1);
19 is(groupItemTwo.getChildren().length, 1, "The number of tabs in group two is 1");
20
21 cw.UI.setActive(groupItemOne);
22
23 moveTabToAnotherGroup(win, groupItemOne.getChild(2).tab, groupItemOne, groupItemTwo, function() {
24 moveTabToAnotherGroup(win, groupItemOne.getChild(1).tab, groupItemOne, groupItemTwo, function() {
25 groupItemOne.close();
26 promiseWindowClosed(win).then(finish);
27 });
28 });
29 });
30 });
31 }
32
33 function moveTabToAnotherGroup(win, targetTab, groupItemOne, groupItemTwo, callback) {
34 hideTabView(function() {
35 let tabCountInGroupItemOne = groupItemOne.getChildren().length;
36 let tabCountInGroupItemTwo = groupItemTwo.getChildren().length;
37
38 win.TabView.moveTabTo(targetTab, groupItemTwo.id);
39
40 showTabView(function() {
41 is(groupItemOne.getChildren().length, --tabCountInGroupItemOne, "The number of tab items in group one is decreased");
42 is(groupItemTwo.getChildren().length, ++tabCountInGroupItemTwo, "The number of tab items in group two is increased");
43 is(groupItemTwo.getChild(tabCountInGroupItemTwo-1).tab, targetTab, "The last tab is the moved tab");
44
45 callback();
46 }, win);
47 }, win);
48 }

mercurial