Bug 1527898 - Override find and replace commands when disableSearchAddon is true; r=gl.

This is an hotfix for the bug, which we want to uplift.
A better fix will happen in Bug 1527903.

Depends on D19963

Differential Revision: https://phabricator.services.mozilla.com/D19965

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Chevobbe 2019-02-18 04:35:42 +00:00
parent d0dfd717b5
commit fbd29e33c8
3 changed files with 49 additions and 0 deletions

View File

@ -433,6 +433,19 @@ Editor.prototype = {
if (!this.config.disableSearchAddon) {
this._initSearchShortcuts(win);
} else {
// Hotfix for Bug 1527898. We should remove those overrides as part of Bug 1527903.
Object.assign(win.CodeMirror.commands, {
find: null,
findPersistent: null,
findPersistentNext: null,
findPersistentPrev: null,
findNext: null,
findPrev: null,
clearSearch: null,
replace: null,
replaceAll: null,
});
}
editors.set(this, cm);

View File

@ -33,6 +33,7 @@ support-files =
[browser_editor_alt_b_f.js]
[browser_editor_basic.js]
[browser_editor_cursor.js]
[browser_editor_disableSearchAddon.js]
[browser_editor_find_again.js]
[browser_editor_goto_line.js]
[browser_editor_history.js]

View File

@ -0,0 +1,35 @@
/* 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 {LocalizationHelper} = require("devtools/shared/l10n");
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);
});