summaryrefslogtreecommitdiffstats
path: root/browser/components/downloads/test/browser/browser_downloads_panel_ctrl_click.js
blob: 57ef284bc1d1eb2c8728b1bc80821a02b5464d5b (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
25
26
27
28
29
30
31
32
33
34
35
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function test_downloads_panel() {
  // On macOS, ctrl-click shouldn't open the panel because this normally opens
  // the context menu. This happens via the `contextmenu` event which is created
  // by widget code, so our simulated clicks do not do so, so we can't test
  // anything on macOS.
  if (AppConstants.platform == "macosx") {
    ok(true, "The test is ignored on Mac");
    return;
  }

  await SpecialPowers.pushPrefEnv({
    set: [["browser.download.autohideButton", false]],
  });
  await promiseButtonShown("downloads-button");

  const button = document.getElementById("downloads-button");
  let shownPromise = promisePanelOpened();
  // Should still open the panel when Ctrl key is pressed.
  EventUtils.synthesizeMouseAtCenter(button, { ctrlKey: true });
  await shownPromise;
  is(DownloadsPanel.panel.state, "open", "Check that panel state is 'open'");

  // Close download panel
  DownloadsPanel.hidePanel();
  is(
    DownloadsPanel.panel.state,
    "closed",
    "Check that panel state is 'closed'"
  );
});