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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 let contentWindow;
     5 let pinnedTab;
     7 function test() {
     8   waitForExplicitFinish();
    10   registerCleanupFunction(function() {
    11     while (gBrowser.tabs[1])
    12       gBrowser.removeTab(gBrowser.tabs[1]);
    13     hideTabView();
    14   });
    16   pinnedTab = gBrowser.addTab("about:blank");
    17   gBrowser.pinTab(pinnedTab);
    18   ok(pinnedTab.pinned, "Tab 1 is pinned");
    20   gBrowser.addTab("about:mozilla");
    21   showTabView(setup);
    22 }
    24 function setup() {
    25   let prefix = "setup: ";
    27   registerCleanupFunction(function() {
    28     let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
    29     if (groupItem)
    30       closeGroupItem(groupItem);
    31   });
    33   contentWindow = TabView.getContentWindow();
    34   let groupItemOne = contentWindow.GroupItems.groupItems[0];
    36   is(contentWindow.GroupItems.groupItems.length, 1,
    37     prefix + "There is only one group");
    39   is(groupItemOne.getChildren().length, 2,
    40     prefix + "The number of tabs in group one is 2");
    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;
    47   // Add a new tab to the second group, from where we will execute the switch
    48   // to tab.
    49   groupItemTwo.newTab("about:blank");
    51   is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo, 
    52      prefix + "The group two is the active group");
    54   is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(1), 
    55      prefix + "The second tab item in group two is active");
    57   hideTabView(function () { switchToURL(groupItemOne, groupItemTwo) } );
    58 }
    61 function switchToURL(groupItemOne, groupItemTwo) {
    62   let prefix = "after switching: ";
    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", {});
    76   // Focus on the app tab.
    77   EventUtils.synthesizeKey("1", { accelKey: true });
    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");
    84   is(groupItemOne.getChildren().length, 2,
    85     prefix + "The number of tabs in group one is 2");
    87   is(groupItemTwo.getChildren().length, 1,
    88     prefix + "The number of tabs in group two is 1");
    90   gBrowser.removeTab(pinnedTab);
    91   finish();
    92 }

mercurial