|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let contentWindow; |
|
5 let pinnedTab; |
|
6 |
|
7 function test() { |
|
8 waitForExplicitFinish(); |
|
9 |
|
10 registerCleanupFunction(function() { |
|
11 while (gBrowser.tabs[1]) |
|
12 gBrowser.removeTab(gBrowser.tabs[1]); |
|
13 hideTabView(); |
|
14 }); |
|
15 |
|
16 pinnedTab = gBrowser.addTab("about:blank"); |
|
17 gBrowser.pinTab(pinnedTab); |
|
18 ok(pinnedTab.pinned, "Tab 1 is pinned"); |
|
19 |
|
20 gBrowser.addTab("about:mozilla"); |
|
21 showTabView(setup); |
|
22 } |
|
23 |
|
24 function setup() { |
|
25 let prefix = "setup: "; |
|
26 |
|
27 registerCleanupFunction(function() { |
|
28 let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId); |
|
29 if (groupItem) |
|
30 closeGroupItem(groupItem); |
|
31 }); |
|
32 |
|
33 contentWindow = TabView.getContentWindow(); |
|
34 let groupItemOne = contentWindow.GroupItems.groupItems[0]; |
|
35 |
|
36 is(contentWindow.GroupItems.groupItems.length, 1, |
|
37 prefix + "There is only one group"); |
|
38 |
|
39 is(groupItemOne.getChildren().length, 2, |
|
40 prefix + "The number of tabs in group one is 2"); |
|
41 |
|
42 // Create a second group with a dummy page. |
|
43 let groupItemTwo = |
|
44 createGroupItemWithTabs(window, 300, 300, 310, ["about:blank"]); |
|
45 let groupItemTwoId = groupItemTwo.id; |
|
46 |
|
47 // Add a new tab to the second group, from where we will execute the switch |
|
48 // to tab. |
|
49 groupItemTwo.newTab("about:blank"); |
|
50 |
|
51 is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo, |
|
52 prefix + "The group two is the active group"); |
|
53 |
|
54 is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(1), |
|
55 prefix + "The second tab item in group two is active"); |
|
56 |
|
57 hideTabView(function () { switchToURL(groupItemOne, groupItemTwo) } ); |
|
58 } |
|
59 |
|
60 |
|
61 function switchToURL(groupItemOne, groupItemTwo) { |
|
62 let prefix = "after switching: "; |
|
63 |
|
64 /** |
|
65 * At this point, focus is on group two. Let's switch to a tab with an URL |
|
66 * contained in group one and then go to the pinned tab after the |
|
67 * switch. The selected group should be group one. |
|
68 */ |
|
69 // Set the urlbar to include the moz-action. |
|
70 gURLBar.value = "moz-action:switchtab,about:mozilla"; |
|
71 // Focus the urlbar so we can press enter. |
|
72 gURLBar.focus(); |
|
73 // Press enter. |
|
74 EventUtils.synthesizeKey("VK_RETURN", {}); |
|
75 |
|
76 // Focus on the app tab. |
|
77 EventUtils.synthesizeKey("1", { accelKey: true }); |
|
78 |
|
79 // Check group one is active after a "switch to tab" action was executed and |
|
80 // the app tab receives focus. |
|
81 is(contentWindow.GroupItems.getActiveGroupItem(), groupItemOne, |
|
82 prefix + "The group one is the active group"); |
|
83 |
|
84 is(groupItemOne.getChildren().length, 2, |
|
85 prefix + "The number of tabs in group one is 2"); |
|
86 |
|
87 is(groupItemTwo.getChildren().length, 1, |
|
88 prefix + "The number of tabs in group two is 1"); |
|
89 |
|
90 gBrowser.removeTab(pinnedTab); |
|
91 finish(); |
|
92 } |