browser/components/tabview/test/browser_tabview_bug716880.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial