|
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/. */ |
|
4 |
|
5 function test() { |
|
6 gPrefService.setBoolPref("browser.ctrlTab.previews", true); |
|
7 |
|
8 let [origTab] = gBrowser.visibleTabs; |
|
9 let tabOne = gBrowser.addTab(); |
|
10 let tabTwo = gBrowser.addTab(); |
|
11 |
|
12 // test the ctrlTab.tabList |
|
13 pressCtrlTab(); |
|
14 ok(ctrlTab.tabList.length, 3, "Show 3 tabs in tab preview"); |
|
15 releaseCtrl(); |
|
16 |
|
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"); |
|
21 |
|
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(); |
|
26 |
|
27 // cleanup |
|
28 gBrowser.removeTab(tabOne); |
|
29 gBrowser.removeTab(tabTwo); |
|
30 |
|
31 if (gPrefService.prefHasUserValue("browser.ctrlTab.previews")) |
|
32 gPrefService.clearUserPref("browser.ctrlTab.previews"); |
|
33 } |
|
34 |
|
35 function pressCtrlTab(aShiftKey) { |
|
36 EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true, shiftKey: !!aShiftKey }); |
|
37 } |
|
38 |
|
39 function releaseCtrl() { |
|
40 EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" }); |
|
41 } |