summaryrefslogtreecommitdiffstats
path: root/devtools/client/shared/sourceeditor/test/browser_editor_disableSearchAddon.js
blob: 8c803786e696c77e66b242bfa6c05507b50a14e9 (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
37
38
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Ensure disableSearchAddon config works as expected in the source editor.

const isMacOS = Services.appinfo.OS === "Darwin";
const L10N = new LocalizationHelper(
  "devtools/client/locales/sourceeditor.properties"
);

const FIND_KEY = L10N.getStr("find.key");
const REPLACE_KEY = L10N.getStr(
  isMacOS ? "replaceAllMac.key" : "replaceAll.key"
);

add_task(async function () {
  const { ed, win } = await setup({
    disableSearchAddon: true,
  });

  const edDoc = ed.container.contentDocument;
  const edWin = edDoc.defaultView;

  await promiseWaitForFocus();
  ed.focus();

  synthesizeKeyShortcut(FIND_KEY, edWin);
  const searchInput = edDoc.querySelector("input[type=search]");
  ok(!searchInput, "the search input is not displayed");

  synthesizeKeyShortcut(REPLACE_KEY, edWin);
  const replaceInput = edDoc.querySelector(".CodeMirror-dialog > input");
  ok(!replaceInput, "the replace input is not displayed");

  teardown(ed, win);
});