michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() { michael@0: gPrefService.setBoolPref("browser.ctrlTab.previews", true); michael@0: michael@0: let [origTab] = gBrowser.visibleTabs; michael@0: let tabOne = gBrowser.addTab(); michael@0: let tabTwo = gBrowser.addTab(); michael@0: michael@0: // test the ctrlTab.tabList michael@0: pressCtrlTab(); michael@0: ok(ctrlTab.tabList.length, 3, "Show 3 tabs in tab preview"); michael@0: releaseCtrl(); michael@0: michael@0: gBrowser.showOnlyTheseTabs([origTab]); michael@0: pressCtrlTab(); michael@0: ok(ctrlTab.tabList.length, 1, "Show 1 tab in tab preview"); michael@0: ok(!ctrlTab.isOpen, "With 1 tab open, Ctrl+Tab doesn't open the preview panel"); michael@0: michael@0: gBrowser.showOnlyTheseTabs([origTab, tabOne, tabTwo]); michael@0: pressCtrlTab(); michael@0: ok(ctrlTab.isOpen, "With 3 tabs open, Ctrl+Tab does open the preview panel"); michael@0: releaseCtrl(); michael@0: michael@0: // cleanup michael@0: gBrowser.removeTab(tabOne); michael@0: gBrowser.removeTab(tabTwo); michael@0: michael@0: if (gPrefService.prefHasUserValue("browser.ctrlTab.previews")) michael@0: gPrefService.clearUserPref("browser.ctrlTab.previews"); michael@0: } michael@0: michael@0: function pressCtrlTab(aShiftKey) { michael@0: EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true, shiftKey: !!aShiftKey }); michael@0: } michael@0: michael@0: function releaseCtrl() { michael@0: EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" }); michael@0: }