Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 function test() {
5 waitForExplicitFinish();
7 newWindowWithTabView(part1);
8 }
10 function part1(win) {
11 registerCleanupFunction(function() win.close());
13 let contentWindow = win.TabView.getContentWindow();
14 is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
16 let originalTab = win.gBrowser.selectedTab;
17 let originalGroup = contentWindow.GroupItems.groupItems[0];
18 let newTab = win.gBrowser.loadOneTab("about:blank", {inBackground: true});
20 is(originalGroup.getChildren().length, 2, "The original group now has two tabs");
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});
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");
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 }
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 }
63 function part2(win) {
64 registerCleanupFunction(function() win.close());
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");
71 // switch the selected tab to new tab
72 win.gBrowser.selectedTab = newTab;
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 }