browser/components/tabview/test/browser_tabview_bug597980.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:689d8ab3e174
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(part1);
8 }
9
10 function part1(win) {
11 registerCleanupFunction(function() win.close());
12
13 let contentWindow = win.TabView.getContentWindow();
14 is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
15
16 let originalTab = win.gBrowser.selectedTab;
17 let originalGroup = contentWindow.GroupItems.groupItems[0];
18 let newTab = win.gBrowser.loadOneTab("about:blank", {inBackground: true});
19
20 is(originalGroup.getChildren().length, 2, "The original group now has two tabs");
21
22 // create group two with the new tab
23 let box = new contentWindow.Rect(300,300,150,150);
24 let newGroup = new contentWindow.GroupItem([], {bounds: box, immediately: true});
25 newGroup.add(newTab._tabViewTabItem, {immediately: true});
26
27 // ensure active group item and tab
28 contentWindow.UI.setActive(originalGroup);
29 is(contentWindow.GroupItems.getActiveGroupItem(), originalGroup,
30 "The original group is active");
31 is(contentWindow.UI.getActiveTab(), originalTab._tabViewTabItem,
32 "The original tab is active");
33
34 function checkActive(callback, time) {
35 is(contentWindow.GroupItems.getActiveGroupItem(), newGroup,
36 "The new group is active");
37 is(contentWindow.UI.getActiveTab(), newTab._tabViewTabItem,
38 "The new tab is active");
39 if (time)
40 setTimeout(callback, time);
41 else
42 callback();
43 }
44
45 // click on the new tab, and check that the new tab and group are active
46 // at two times: 10 ms after (still during the animation) and
47 // 500 ms after (after the animation, hopefully). Either way, the new
48 // tab and group should be active.
49 EventUtils.sendMouseEvent({ type: "mousedown" },
50 newTab._tabViewTabItem.container, contentWindow);
51 EventUtils.sendMouseEvent({ type: "mouseup" },
52 newTab._tabViewTabItem.container, contentWindow);
53 setTimeout(function() {
54 checkActive(function() {
55 checkActive(function() {
56 win.close();
57 newWindowWithTabView(part2);
58 });
59 }, 490);
60 }, 10)
61 }
62
63 function part2(win) {
64 registerCleanupFunction(function() win.close());
65
66 let newTab = win.gBrowser.loadOneTab("about:blank", {inBackground: true});
67 hideTabView(function() {
68 let selectedTab = win.gBrowser.selectedTab;
69 isnot(selectedTab, newTab, "They are different tabs");
70
71 // switch the selected tab to new tab
72 win.gBrowser.selectedTab = newTab;
73
74 showTabView(function () {
75 hideTabView(function () {
76 is(win.gBrowser.selectedTab, newTab,
77 "The selected tab should be the same as before (new tab)");
78 waitForFocus(finish);
79 }, win);
80 }, win);
81 }, win);
82 }

mercurial