browser/components/tabview/test/browser_tabview_bug715454.js

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

mercurial