summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_character_encoding_ctrl_click.js
blob: d2f2684eebbca7edd3ed4b30fa2a45f2de286fd4 (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
36
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function test_character_encoding_menu() {
  // 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;
  }

  CustomizableUI.addWidgetToArea(
    "characterencoding-button",
    CustomizableUI.AREA_NAVBAR,
    4
  );

  const button = document.getElementById("characterencoding-button");
  EventUtils.synthesizeMouseAtCenter(button, { ctrlKey: true });

  const view = document.getElementById("PanelUI-characterEncodingView");
  let shownPromise = subviewShown(view);
  await shownPromise;
  ok(true, "Character encoding menu shown after button pressed");

  // Close character encoding popup.
  let hiddenPromise = subviewHidden(view);
  view.closest("panel").hidePopup();
  await hiddenPromise;

  CustomizableUI.reset();
});