browser/base/content/test/general/browser_bug580638.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 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 function test() {
     6   waitForExplicitFinish();
     8   function testState(aPinned) {
     9     function elemAttr(id, attr) document.getElementById(id).getAttribute(attr);
    11     if (aPinned) {
    12       is(elemAttr("key_close", "disabled"), "true",
    13          "key_close should be disabled when a pinned-tab is selected");
    14       is(elemAttr("menu_close", "key"), "",
    15          "menu_close shouldn't have a key set when a pinned is selected");
    16     }
    17     else {
    18       is(elemAttr("key_close", "disabled"), "",
    19          "key_closed shouldn't have disabled state set when a non-pinned tab is selected");
    20       is(elemAttr("menu_close", "key"), "key_close",
    21          "menu_close should have key_close set as its key when a non-pinned tab is selected");
    22     }
    23   }
    25   let lastSelectedTab = gBrowser.selectedTab;
    26   ok(!lastSelectedTab.pinned, "We should have started with a regular tab selected");
    28   testState(false);
    30   let pinnedTab = gBrowser.addTab("about:blank");
    31   gBrowser.pinTab(pinnedTab);
    33   // Just pinning the tab shouldn't change the key state.
    34   testState(false);
    36   // Test updating key state after selecting a tab.
    37   gBrowser.selectedTab = pinnedTab;
    38   testState(true);
    40   gBrowser.selectedTab = lastSelectedTab;
    41   testState(false);
    43   gBrowser.selectedTab = pinnedTab;
    44   testState(true);
    46   // Test updating the key state after un/pinning the tab.
    47   gBrowser.unpinTab(pinnedTab);
    48   testState(false);
    50   gBrowser.pinTab(pinnedTab);  
    51   testState(true);
    53   // Test updating the key state after removing the tab.
    54   gBrowser.removeTab(pinnedTab);
    55   testState(false);
    57   finish();
    58 }

mercurial