summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/sidebar/browser_sidebar_keys.js
blob: 2c9817d5b008d87d43527576b7dd22a0cf870636 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

async function testSidebarKeyToggle(key, options, expectedSidebarId) {
  EventUtils.synthesizeMouseAtCenter(gURLBar.textbox, {});
  let promiseShown = BrowserTestUtils.waitForEvent(window, "SidebarShown");
  EventUtils.synthesizeKey(key, options);
  await promiseShown;
  Assert.equal(
    document.getElementById("sidebar-box").getAttribute("sidebarcommand"),
    expectedSidebarId
  );
  EventUtils.synthesizeKey(key, options);
  Assert.ok(!SidebarUI.isOpen);
}

add_task(async function test_sidebar_keys() {
  registerCleanupFunction(() => SidebarUI.hide());

  await testSidebarKeyToggle("b", { accelKey: true }, "viewBookmarksSidebar");

  let options = { accelKey: true, shiftKey: AppConstants.platform == "macosx" };
  await testSidebarKeyToggle("h", options, "viewHistorySidebar");
});