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

mercurial