Bug 1820593 - Convert AsyncSpellCheckTestHelper to an ES module. r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D171748
This commit is contained in:
Mark Banner 2023-03-07 09:40:39 +00:00
Родитель 7cbf20e7cb
Коммит 9bbd275235
6 изменённых файлов: 13 добавлений и 17 удалений

Просмотреть файл

@ -26,8 +26,8 @@ function openContextMenuFor(element, shiftkey, waitForSpellCheck) {
}
if (waitForSpellCheck) {
var { onSpellCheck } = SpecialPowers.ChromeUtils.import(
"resource://testing-common/AsyncSpellCheckTestHelper.jsm"
var { onSpellCheck } = SpecialPowers.ChromeUtils.importESModule(
"resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs"
);
onSpellCheck(element, actuallyOpenContextMenuFor);
} else {
@ -364,8 +364,8 @@ async function test_contextmenu(selector, menuItems, options = {}) {
gBrowser.selectedBrowser,
[selector],
async function(contentSelector) {
let { onSpellCheck } = ChromeUtils.import(
"resource://testing-common/AsyncSpellCheckTestHelper.jsm"
let { onSpellCheck } = ChromeUtils.importESModule(
"resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs"
);
let element = content.document.querySelector(contentSelector);
await new Promise(resolve => onSpellCheck(element, resolve));

Просмотреть файл

@ -2,12 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = [
"maybeOnSpellCheck",
"onSpellCheck",
"getDictionaryContentPref",
];
const SPELL_CHECK_ENDED_TOPIC = "inlineSpellChecker-spellCheck-ended";
const SPELL_CHECK_STARTED_TOPIC = "inlineSpellChecker-spellCheck-started";
@ -32,7 +26,7 @@ const CP = Cc["@mozilla.org/content-pref/service;1"].getService(
* of the event loop have passed to determine it has not
* started.
*/
function maybeOnSpellCheck(editableElement, callback) {
export function maybeOnSpellCheck(editableElement, callback) {
let editor = editableElement.editor;
if (!editor) {
let win = editableElement.ownerGlobal;
@ -103,7 +97,7 @@ function maybeOnSpellCheck(editableElement, callback) {
* of the event loop have passed to determine it has not
* started.
*/
function onSpellCheck(editableElement, callback) {
export function onSpellCheck(editableElement, callback) {
const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
@ -114,7 +108,7 @@ function onSpellCheck(editableElement, callback) {
);
}
async function getDictionaryContentPref() {
export async function getDictionaryContentPref() {
let dictionaries = await new Promise(resolve => {
let value = "";
CP.getByDomainAndName("mochi.test", "spellcheck.lang", null, {

Просмотреть файл

@ -27,7 +27,7 @@ XPIDL_SOURCES += [
XPIDL_MODULE = "editor"
TESTING_JS_MODULES += [
"AsyncSpellCheckTestHelper.jsm",
"AsyncSpellCheckTestHelper.sys.mjs",
]
with Files("**"):

Просмотреть файл

@ -51,7 +51,7 @@ reftest.jar:
res/reftest-content.js (reftest-content.js)
res/ReftestFissionParent.jsm (ReftestFissionParent.jsm)
res/ReftestFissionChild.jsm (ReftestFissionChild.jsm)
res/AsyncSpellCheckTestHelper.jsm (../../../editor/AsyncSpellCheckTestHelper.jsm)
res/AsyncSpellCheckTestHelper.sys.mjs (../../../editor/AsyncSpellCheckTestHelper.sys.mjs)
res/httpd.jsm (../../../netwerk/test/httpserver/httpd.js)
res/StructuredLog.sys.mjs (../../../testing/modules/StructuredLog.sys.mjs)
res/PerTestCoverageUtils.sys.mjs (../../../tools/code-coverage/PerTestCoverageUtils.sys.mjs)

Просмотреть файл

@ -18,8 +18,8 @@ const BLANK_URL_FOR_CLEARING = "data:text/html;charset=UTF-8,%3C%21%2D%2DCLEAR%2
const { setTimeout, clearTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
const { onSpellCheck } = ChromeUtils.import(
"resource://reftest/AsyncSpellCheckTestHelper.jsm"
const { onSpellCheck } = ChromeUtils.importESModule(
"resource://reftest/AsyncSpellCheckTestHelper.sys.mjs"
);
// This will load chrome Custom Elements inside chrome documents:

Просмотреть файл

@ -1798,6 +1798,8 @@
"toolkit/components/pdfjs/content/build/pdf.sandbox.external.js",
"resource://reftest/AsyncSpellCheckTestHelper.jsm":
"editor/AsyncSpellCheckTestHelper.jsm",
"resource://testing-common/AsyncSpellCheckTestHelper.jsm":
"editor/AsyncSpellCheckTestHelper.jsm",
"resource://reftest/PerTestCoverageUtils.jsm":
"tools/code-coverage/PerTestCoverageUtils.jsm",
"resource://reftest/ReftestFissionChild.jsm":