browser/base/content/test/general/browser_visibleTabs_tabPreview.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   gPrefService.setBoolPref("browser.ctrlTab.previews", true);
     8   let [origTab] = gBrowser.visibleTabs;
     9   let tabOne = gBrowser.addTab();
    10   let tabTwo = gBrowser.addTab();
    12   // test the ctrlTab.tabList
    13   pressCtrlTab();
    14   ok(ctrlTab.tabList.length, 3, "Show 3 tabs in tab preview");
    15   releaseCtrl();
    17   gBrowser.showOnlyTheseTabs([origTab]);
    18   pressCtrlTab();
    19   ok(ctrlTab.tabList.length, 1, "Show 1 tab in tab preview");
    20   ok(!ctrlTab.isOpen, "With 1 tab open, Ctrl+Tab doesn't open the preview panel");
    22   gBrowser.showOnlyTheseTabs([origTab, tabOne, tabTwo]);
    23   pressCtrlTab();
    24   ok(ctrlTab.isOpen, "With 3 tabs open, Ctrl+Tab does open the preview panel");
    25   releaseCtrl();
    27   // cleanup
    28   gBrowser.removeTab(tabOne);
    29   gBrowser.removeTab(tabTwo);
    31   if (gPrefService.prefHasUserValue("browser.ctrlTab.previews"))
    32     gPrefService.clearUserPref("browser.ctrlTab.previews");
    33 }
    35 function pressCtrlTab(aShiftKey) {
    36   EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true, shiftKey: !!aShiftKey });
    37 }
    39 function releaseCtrl() {
    40   EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" });
    41 }

mercurial