browser/base/content/test/general/browser_visibleTabs_tabPreview.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/general/browser_visibleTabs_tabPreview.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +function test() {
     1.9 +  gPrefService.setBoolPref("browser.ctrlTab.previews", true);
    1.10 +
    1.11 +  let [origTab] = gBrowser.visibleTabs;
    1.12 +  let tabOne = gBrowser.addTab();
    1.13 +  let tabTwo = gBrowser.addTab();
    1.14 +
    1.15 +  // test the ctrlTab.tabList
    1.16 +  pressCtrlTab();
    1.17 +  ok(ctrlTab.tabList.length, 3, "Show 3 tabs in tab preview");
    1.18 +  releaseCtrl();
    1.19 +
    1.20 +  gBrowser.showOnlyTheseTabs([origTab]);
    1.21 +  pressCtrlTab();
    1.22 +  ok(ctrlTab.tabList.length, 1, "Show 1 tab in tab preview");
    1.23 +  ok(!ctrlTab.isOpen, "With 1 tab open, Ctrl+Tab doesn't open the preview panel");
    1.24 +
    1.25 +  gBrowser.showOnlyTheseTabs([origTab, tabOne, tabTwo]);
    1.26 +  pressCtrlTab();
    1.27 +  ok(ctrlTab.isOpen, "With 3 tabs open, Ctrl+Tab does open the preview panel");
    1.28 +  releaseCtrl();
    1.29 +
    1.30 +  // cleanup
    1.31 +  gBrowser.removeTab(tabOne);
    1.32 +  gBrowser.removeTab(tabTwo);
    1.33 +
    1.34 +  if (gPrefService.prefHasUserValue("browser.ctrlTab.previews"))
    1.35 +    gPrefService.clearUserPref("browser.ctrlTab.previews");
    1.36 +}
    1.37 +
    1.38 +function pressCtrlTab(aShiftKey) {
    1.39 +  EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true, shiftKey: !!aShiftKey });
    1.40 +}
    1.41 +
    1.42 +function releaseCtrl() {
    1.43 +  EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" });
    1.44 +}

mercurial