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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 let contentWindow;
     6 function test() {
     7   waitForExplicitFinish();
     9   registerCleanupFunction(function() {
    10     while (gBrowser.tabs[1])
    11       gBrowser.removeTab(gBrowser.tabs[1]);
    12     hideTabView();
    13   });
    15   gBrowser.addTab("about:mozilla");
    16   showTabView(setup);
    17 }
    20 function setup() {
    21   let prefix = "setup: ";
    23   registerCleanupFunction(function() {
    24     let groupItem =  contentWindow.GroupItems.groupItem(groupItemTwoId);
    25     if (groupItem)
    26       closeGroupItem(groupItem);
    27   });
    29   contentWindow = TabView.getContentWindow();
    30   let groupItemOne = contentWindow.GroupItems.groupItems[0];
    32   contentWindow = TabView.getContentWindow();
    33   is(contentWindow.GroupItems.groupItems.length, 1,
    34     prefix + "There is only one group");
    36   is(groupItemOne.getChildren().length, 2,
    37     prefix + "The number of tabs in group one is 2");
    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;
    44   // Add a new tab to the second group, from where we will execute the switch
    45   // to tab.
    46   groupItemTwo.newTab("about:blank");
    48   is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo, 
    49      prefix + "The group two is the active group");
    51   is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(1), 
    52      prefix + "The second tab item in group two is active");
    54   hideTabView(function () { switchToURL(groupItemOne, groupItemTwo) } );
    55 }
    58 function switchToURL(groupItemOne, groupItemTwo) {
    59   let prefix = "after switching: ";
    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", {});
    73   // Open a new tab and make sure the tab is opened in the group one.
    74   EventUtils.synthesizeKey("t", { accelKey: true });
    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");
    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");
    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");
    89   finish();
    90 }

mercurial