Bug 1799314 - Convert most of the JSM modules in testing/ to ES modules. r=ahal

Differential Revision: https://phabricator.services.mozilla.com/D161431
This commit is contained in:
Mark Banner 2022-11-17 12:00:25 +00:00
Родитель bf5f3727e8
Коммит 24f6e8a8ca
50 изменённых файлов: 284 добавлений и 403 удалений

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

@ -1920,7 +1920,6 @@ module.exports = {
"security/manager/ssl/tests/mochitest/mixedcontent/test_dynUnsecurePicture.html",
"security/manager/ssl/tests/mochitest/mixedcontent/test_dynUnsecurePicturePreload.html",
"security/sandbox/test/browser_bug1393259.js",
"testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm ",
"testing/mochitest/chrome/test_sanityEventUtils.xhtml",
"testing/mochitest/server.js",
"testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html",

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

@ -20,7 +20,7 @@ const kDumpAllStacks = false;
const known_scripts = {
modules: new Set([
"chrome://mochikit/content/ShutdownLeaksCollector.jsm",
"chrome://mochikit/content/ShutdownLeaksCollector.sys.mjs",
// General utilities
"resource://gre/modules/AppConstants.sys.mjs",
@ -85,11 +85,11 @@ const intermittently_loaded_scripts = {
// Test related
"chrome://remote/content/marionette/actors/MarionetteEventsChild.sys.mjs",
"chrome://remote/content/shared/Log.sys.mjs",
"resource://testing-common/BrowserTestUtilsChild.jsm",
"resource://testing-common/ContentEventListenerChild.jsm",
"resource://specialpowers/AppTestDelegateChild.jsm",
"resource://specialpowers/SpecialPowersChild.jsm",
"resource://specialpowers/WrapPrivileged.jsm",
"resource://testing-common/BrowserTestUtilsChild.sys.mjs",
"resource://testing-common/ContentEventListenerChild.sys.mjs",
"resource://specialpowers/AppTestDelegateChild.sys.mjs",
"resource://specialpowers/SpecialPowersChild.sys.mjs",
"resource://specialpowers/WrapPrivileged.sys.mjs",
]),
frameScripts: new Set([]),
processScripts: new Set([

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

@ -74,11 +74,11 @@ const intermittently_loaded_scripts = {
// Test related
"chrome://remote/content/marionette/actors/MarionetteEventsChild.sys.mjs",
"chrome://remote/content/shared/Log.sys.mjs",
"resource://testing-common/BrowserTestUtilsChild.jsm",
"resource://testing-common/ContentEventListenerChild.jsm",
"resource://specialpowers/SpecialPowersChild.jsm",
"resource://specialpowers/AppTestDelegateChild.jsm",
"resource://specialpowers/WrapPrivileged.jsm",
"resource://testing-common/BrowserTestUtilsChild.sys.mjs",
"resource://testing-common/ContentEventListenerChild.sys.mjs",
"resource://specialpowers/SpecialPowersChild.sys.mjs",
"resource://specialpowers/AppTestDelegateChild.sys.mjs",
"resource://specialpowers/WrapPrivileged.sys.mjs",
]),
processScripts: new Set([]),
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -59,8 +59,8 @@ js_source_path = [
"../testing/mochitest/BrowserTestUtils",
"../testing/mochitest/tests/SimpleTest/SimpleTest.js",
"../testing/mochitest/tests/SimpleTest/EventUtils.js",
"../testing/modules/Assert.jsm",
"../testing/modules/TestUtils.jsm",
"../testing/modules/Assert.sys.mjs",
"../testing/modules/TestUtils.sys.mjs",
"../toolkit/actors",
"../toolkit/components/extensions",
"../toolkit/components/extensions/parent",

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

@ -18,8 +18,6 @@ add_task(async function dragimage_remote_tab() {
let image = content.document.body.firstElementChild;
let target = content.document.body.lastElementChild;
const EventUtils = ContentTaskUtils.getEventUtils(content);
await EventUtils.synthesizePlainDragAndDrop({
srcElement: image,
destElement: target,

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

@ -34,7 +34,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1560741
});
let checkRequest = async (expectedResponse, msg) => {
/* import-globals-from ../../../../testing/modules/Assert.jsm */
let response = await this.content.Notification.requestPermission();
Assert.equal(response, expectedResponse, msg);
};
@ -44,7 +43,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1560741
checkRequest);
let checkPermission = async (expectedPermission, msg) => {
/* import-globals-from ../../../../testing/modules/Assert.jsm */
let permission = this.content.Notification.permission;
Assert.equal(permission, expectedPermission, msg);
};

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

@ -295,7 +295,6 @@ function test_cross_iframe_contentDocument_no_allow() {
ifr.setAttribute("src", "https://example.org/tests/dom/security/featurePolicy/test/mochitest/empty.html");
ifr.onload = async function() {
await SpecialPowers.spawn(ifr, [], () => {
/* import-globals-from ../../../../../testing/modules/Assert.jsm */
Assert.ok("featurePolicy" in this.content.document, "We have this.content.document.featurePolicy");
Assert.ok(!this.content.document.featurePolicy.allowsFeature("foobar"), "Random feature");

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

@ -6,7 +6,7 @@ Firefox browser window. The test files are named `browser_something.js` by
convention, and in addition to mochitest assertions supports the
[CommonJS standard assertions](http://wiki.commonjs.org/wiki/Unit_Testing/1.1),
like [nodejs' assert module](https://nodejs.org/api/assert.html#assert) but
implemented in [`Assert.jsm`](../assert.rst).
implemented in [`Assert.sys.mjs`](../assert.rst).
These tests are used to test UI-related behaviour in Firefox for
Desktop. They do not run on Android. If you're testing internal code that

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

@ -142,7 +142,7 @@ For operations that are common to a specific set of tests, you can use the `head
file to share JS code.
Where code is needed across various directories of tests, you should consider if it's
common enough to warrant being in `BrowserTestUtils.jsm`, or if not, setting up
common enough to warrant being in `BrowserTestUtils.sys.mjs`, or if not, setting up
a separate `jsm` module containing your test helpers. You can add these to
`TESTING_JS_MODULES` in `moz.build` to avoid packaging them with Firefox. They
will be available in `resource://testing-common/` to all tests.

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

@ -12,19 +12,13 @@
// This file uses ContentTask & frame scripts, where these are available.
/* global ContentTaskUtils */
"use strict";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["BrowserTestUtils"];
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
const { ComponentUtils } = ChromeUtils.import(
"resource://gre/modules/ComponentUtils.jsm"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { TestUtils } = ChromeUtils.import(
"resource://testing-common/TestUtils.jsm"
);
@ -82,10 +76,10 @@ const kAboutPageRegistrationContentScript =
function registerActors() {
ChromeUtils.registerWindowActor("BrowserTestUtils", {
parent: {
moduleURI: "resource://testing-common/BrowserTestUtilsParent.jsm",
esModuleURI: "resource://testing-common/BrowserTestUtilsParent.sys.mjs",
},
child: {
moduleURI: "resource://testing-common/BrowserTestUtilsChild.jsm",
esModuleURI: "resource://testing-common/BrowserTestUtilsChild.sys.mjs",
events: {
DOMContentLoaded: { capture: true },
load: { capture: true },
@ -97,10 +91,12 @@ function registerActors() {
ChromeUtils.registerWindowActor("ContentEventListener", {
parent: {
moduleURI: "resource://testing-common/ContentEventListenerParent.jsm",
esModuleURI:
"resource://testing-common/ContentEventListenerParent.sys.mjs",
},
child: {
moduleURI: "resource://testing-common/ContentEventListenerChild.jsm",
esModuleURI:
"resource://testing-common/ContentEventListenerChild.sys.mjs",
events: {
// We need to see the creation of all new windows, in case they have
// a browsing context we are interested in.
@ -122,7 +118,7 @@ registerActors();
*
* @class
*/
var BrowserTestUtils = {
export var BrowserTestUtils = {
/**
* Loads a page in a new tab, executes a Task and closes the tab.
*

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

@ -2,9 +2,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["BrowserTestUtilsChild"];
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
@ -104,7 +101,7 @@ BrowserTestUtilsChildObserver.prototype.QueryInterface = ChromeUtils.generateQI(
["nsIObserver", "nsISupportsWeakReference"]
);
class BrowserTestUtilsChild extends JSWindowActorChild {
export class BrowserTestUtilsChild extends JSWindowActorChild {
actorCreated() {
this._EventUtils = null;
}

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

@ -2,11 +2,8 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["BrowserTestUtilsParent"];
class BrowserTestUtilsParent extends JSWindowActorParent {
export class BrowserTestUtilsParent extends JSWindowActorParent {
receiveMessage(aMessage) {
switch (aMessage.name) {
case "DOMContentLoaded":

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

@ -2,11 +2,8 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["ContentEventListenerChild"];
class ContentEventListenerChild extends JSWindowActorChild {
export class ContentEventListenerChild extends JSWindowActorChild {
actorCreated() {
this._contentEvents = new Map();
this._shutdown = false;

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

@ -2,15 +2,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["ContentEventListenerParent"];
const { BrowserTestUtils } = ChromeUtils.import(
"resource://testing-common/BrowserTestUtils.jsm"
);
class ContentEventListenerParent extends JSWindowActorParent {
export class ContentEventListenerParent extends JSWindowActorParent {
receiveMessage(aMessage) {
switch (aMessage.name) {
case "ContentEventListener:Run": {

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

@ -4,10 +4,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/. */
"use strict";
var EXPORTED_SYMBOLS = ["ContentTask"];
const FRAME_SCRIPT = "resource://testing-common/content-task.js";
/**
@ -28,7 +24,7 @@ var gMessageID = 1;
/**
* This object provides the public module functions.
*/
var ContentTask = {
export var ContentTask = {
/**
* _testScope saves the current testScope from
* browser-test.js. This is used to implement SimpleTest functions

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

@ -14,15 +14,9 @@
/* eslint-disable mozilla/use-ownerGlobal */
"use strict";
import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
var EXPORTED_SYMBOLS = ["ContentTaskUtils"];
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
var ContentTaskUtils = {
export var ContentTaskUtils = {
/**
* Checks if a DOM element is hidden.
*
@ -181,6 +175,7 @@ var ContentTaskUtils = {
let EventUtils = (content._EventUtils = {});
EventUtils.window = {};
EventUtils.setTimeout = setTimeout;
EventUtils.parent = EventUtils.window;
/* eslint-disable camelcase */
EventUtils._EU_Ci = Ci;

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

@ -12,19 +12,22 @@ let { ContentTaskUtils } = ChromeUtils.import(
const { Assert: AssertCls } = ChromeUtils.import(
"resource://testing-common/Assert.jsm"
);
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
// Injects EventUtils into ContentTask scope. To avoid leaks, this does not hold on
// to the window global. This means you **need** to pass the window as an argument to
// the individual EventUtils functions.
// See SimpleTest/EventUtils.js for documentation.
var EventUtils = {};
EventUtils.window = {};
EventUtils.parent = EventUtils.window;
EventUtils._EU_Ci = Ci;
EventUtils._EU_Cc = Cc;
EventUtils.KeyboardEvent = content.KeyboardEvent;
EventUtils.navigator = content.navigator;
var EventUtils = {
_EU_Ci: Ci,
_EU_Cc: Cc,
KeyboardEvent: content.KeyboardEvent,
navigator: content.navigator,
setTimeout,
window: {},
};
EventUtils.synthesizeClick = element =>
new Promise(resolve => {

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

@ -5,12 +5,12 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
TESTING_JS_MODULES += [
"BrowserTestUtils.jsm",
"BrowserTestUtilsChild.jsm",
"BrowserTestUtilsParent.jsm",
"BrowserTestUtils.sys.mjs",
"BrowserTestUtilsChild.sys.mjs",
"BrowserTestUtilsParent.sys.mjs",
"content/content-task.js",
"ContentEventListenerChild.jsm",
"ContentEventListenerParent.jsm",
"ContentTask.jsm",
"ContentTaskUtils.jsm",
"ContentEventListenerChild.sys.mjs",
"ContentEventListenerParent.sys.mjs",
"ContentTask.sys.mjs",
"ContentTaskUtils.sys.mjs",
]

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

@ -2,18 +2,14 @@
* 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/. */
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
var EXPORTED_SYMBOLS = ["ContentCollector"];
import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
// This listens for the message "browser-test:collect-request". When it gets it,
// it runs some GCs and CCs, then prints out a message indicating the collections
// are complete. Mochitest uses this information to determine when windows and
// docshells should be destroyed.
var ContentCollector = {
export var ContentCollector = {
init() {
let processType = Services.appinfo.processType;
if (processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
@ -61,4 +57,5 @@ var ContentCollector = {
Services.cpmm.removeMessageListener("browser-test:collect-request", this);
},
};
ContentCollector.init();

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

@ -32,7 +32,7 @@ FINAL_TARGET_FILES.content += [
"redirect.html",
"server.js",
"shutdown-leaks-collector.js",
"ShutdownLeaksCollector.jsm",
"ShutdownLeaksCollector.sys.mjs",
]
FINAL_TARGET_FILES.content.dynamic += [

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

@ -1284,8 +1284,8 @@ function synthesizeAndWaitNativeMouseMove(
) {
let browser = gBrowser.selectedTab.linkedBrowser;
let mm = browser.messageManager;
let { ContentTask } = _EU_ChromeUtils.import(
"resource://testing-common/ContentTask.jsm"
let { ContentTask } = _EU_ChromeUtils.importESModule(
"resource://testing-common/ContentTask.sys.mjs"
);
let eventRegisteredPromise = new Promise(resolve => {
@ -1436,8 +1436,8 @@ function synthesizeAndWaitKey(
let mm = browser.messageManager;
let keyCode = _createKeyboardEventDictionary(aKey, aEvent, null, aWindow)
.dictionary.keyCode;
let { ContentTask } = _EU_ChromeUtils.import(
"resource://testing-common/ContentTask.jsm"
let { ContentTask } = _EU_ChromeUtils.importESModule(
"resource://testing-common/ContentTask.sys.mjs"
);
let keyRegisteredPromise = new Promise(resolve => {

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

@ -2,10 +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/. */
"use strict";
var EXPORTED_SYMBOLS = ["makeFakeAppDir"];
/* global OS */
Cc["@mozilla.org/net/osfileconstantsservice;1"]
.getService(Ci.nsIOSFileConstantsService)
@ -27,7 +23,7 @@ var gFakeAppDirectoryProvider;
* This returns a promise that will be resolved once the new directory
* is created and installed.
*/
var makeFakeAppDir = function() {
export var makeFakeAppDir = function() {
let dirMode = OS.Constants.libc.S_IRWXU;
let baseFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
let appD = baseFile.clone();

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

@ -2,10 +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/. */
"use strict";
var EXPORTED_SYMBOLS = ["newAppInfo", "getAppInfo", "updateAppInfo"];
let origPlatformInfo = Cc["@mozilla.org/xre/app-info;1"].getService(
Ci.nsIPlatformInfo
);
@ -30,7 +26,7 @@ let origRuntime = Cc["@mozilla.org/xre/app-info;1"].getService(
*
* crashReporter: nsICrashReporter interface is implemented if true
*/
var newAppInfo = function(options = {}) {
export var newAppInfo = function(options = {}) {
let appInfo = {
// nsIXULAppInfo
vendor: "Mozilla",
@ -102,7 +98,7 @@ var currentAppInfo = newAppInfo();
/**
* Obtain a reference to the current object used to define XULAppInfo.
*/
var getAppInfo = function() {
export var getAppInfo = function() {
return currentAppInfo;
};
@ -114,7 +110,7 @@ var getAppInfo = function() {
* To change the current XULAppInfo, simply call this function. If there was
* a previously registered app info object, it will be unloaded and replaced.
*/
var updateAppInfo = function(options) {
export var updateAppInfo = function(options) {
currentAppInfo = newAppInfo(options);
let id = Components.ID("{fbfae60b-64a4-44ef-a911-08ceb70b9f31}");

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

@ -6,10 +6,6 @@
// Copyright (c) 2009 Thomas Robinson <280north.com>
// MIT license: http://opensource.org/licenses/MIT
"use strict";
var EXPORTED_SYMBOLS = ["Assert"];
const { ObjectUtils } = ChromeUtils.import(
"resource://gre/modules/ObjectUtils.jsm"
);
@ -37,7 +33,7 @@ const { ObjectUtils } = ChromeUtils.import(
*
* @class
*/
function Assert(reporterFunc, isDefault) {
export function Assert(reporterFunc, isDefault) {
if (reporterFunc) {
this.setReporter(reporterFunc);
}
@ -132,7 +128,11 @@ Assert.AssertionError = function(options) {
let stack = Components.stack;
do {
stack = stack.asyncCaller || stack.caller;
} while (stack && stack.filename && stack.filename.includes("Assert.jsm"));
} while (
stack &&
stack.filename &&
stack.filename.includes("Assert.sys.mjs")
);
this.stack = stack;
};

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

@ -2,21 +2,15 @@
* 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/. */
"use strict";
import { addDebuggerToGlobal } from "resource://gre/modules/jsdebugger.sys.mjs";
var EXPORTED_SYMBOLS = ["CoverageCollector"];
/* globals Debugger */
const { addDebuggerToGlobal } = ChromeUtils.importESModule(
"resource://gre/modules/jsdebugger.sys.mjs"
);
// eslint-disable-next-line mozilla/reject-globalThis-modification
addDebuggerToGlobal(globalThis);
/**
* Records coverage for each test by way of the js debugger.
*/
var CoverageCollector = function(prefix) {
export var CoverageCollector = function(prefix) {
this._prefix = prefix;
this._dbg = new Debugger();
this._dbg.collectCoverageInfo = true;

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

@ -6,25 +6,16 @@
* Provides testing functions dealing with local files and their contents.
*/
"use strict";
import { DownloadPaths } from "resource://gre/modules/DownloadPaths.sys.mjs";
import { FileUtils } from "resource://gre/modules/FileUtils.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["FileTestUtils"];
const { DownloadPaths } = ChromeUtils.importESModule(
"resource://gre/modules/DownloadPaths.sys.mjs"
);
const { FileUtils } = ChromeUtils.importESModule(
"resource://gre/modules/FileUtils.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm");
let gFileCounter = 1;
let gPathsToRemove = [];
var FileTestUtils = {
export var FileTestUtils = {
/**
* Returns a reference to a temporary file that is guaranteed not to exist and
* to have never been created before. If a file or a directory with this name

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

@ -2,18 +2,13 @@
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["MockRegistrar"];
const Cm = Components.manager;
const { Log } = ChromeUtils.importESModule(
"resource://gre/modules/Log.sys.mjs"
);
import { Log } from "resource://gre/modules/Log.sys.mjs";
var logger = Log.repository.getLogger("MockRegistrar");
var MockRegistrar = Object.freeze({
export var MockRegistrar = Object.freeze({
_registeredComponents: new Map(),
_originalCIDs: new Map(),
get registrar() {

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

@ -2,15 +2,11 @@
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["MockRegistry"];
const { MockRegistrar } = ChromeUtils.import(
"resource://testing-common/MockRegistrar.jsm"
);
class MockRegistry {
export class MockRegistry {
constructor() {
// Three level structure of Maps pointing to Maps pointing to Maps
// this.roots is the top of the structure and has ROOT_KEY_* values

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

@ -16,13 +16,8 @@
* example LoginTestUtils.jsm.
*/
"use strict";
import { clearTimeout, setTimeout } from "resource://gre/modules/Timer.sys.mjs";
var EXPORTED_SYMBOLS = ["TestUtils"];
const { clearTimeout, setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
const ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(
Ci.nsIConsoleAPIStorage
);
@ -33,7 +28,7 @@ const ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(
*
* @class
*/
var TestUtils = {
export var TestUtils = {
executeSoon(callbackFn) {
Services.tm.dispatchToMainThread(callbackFn);
},

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

@ -3,16 +3,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["XPCShellContentUtils"];
const { ExtensionUtils } = ChromeUtils.import(
"resource://gre/modules/ExtensionUtils.jsm"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
// Windowless browsers can create documents that rely on XUL Custom Elements:
ChromeUtils.import("resource://gre/modules/CustomElementsListener.jsm");
@ -292,7 +287,7 @@ class ContentPage {
}
}
var XPCShellContentUtils = {
export var XPCShellContentUtils = {
currentScope: null,
fetchScopes: new Map(),

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

@ -8,22 +8,22 @@ XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"]
BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"]
TESTING_JS_MODULES += [
"AppData.jsm",
"AppInfo.jsm",
"Assert.jsm",
"CoverageUtils.jsm",
"FileTestUtils.jsm",
"MockRegistrar.jsm",
"AppData.sys.mjs",
"AppInfo.sys.mjs",
"Assert.sys.mjs",
"CoverageUtils.sys.mjs",
"FileTestUtils.sys.mjs",
"MockRegistrar.sys.mjs",
"sinon-7.2.7.js",
"Sinon.jsm",
"StructuredLog.jsm",
"TestUtils.jsm",
"XPCShellContentUtils.jsm",
"TestUtils.sys.mjs",
"XPCShellContentUtils.sys.mjs",
]
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
TESTING_JS_MODULES += [
"MockRegistry.jsm",
"MockRegistry.sys.mjs",
]

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

@ -33,23 +33,23 @@ this.specialpowers = class extends ExtensionAPI {
allFrames: true,
includeChrome: true,
child: {
moduleURI: "resource://specialpowers/SpecialPowersChild.jsm",
esModuleURI: "resource://specialpowers/SpecialPowersChild.sys.mjs",
observers: [
"chrome-document-global-created",
"content-document-global-created",
],
},
parent: {
moduleURI: "resource://specialpowers/SpecialPowersParent.jsm",
esModuleURI: "resource://specialpowers/SpecialPowersParent.sys.mjs",
},
});
ChromeUtils.registerWindowActor("AppTestDelegate", {
parent: {
moduleURI: "resource://specialpowers/AppTestDelegateParent.jsm",
esModuleURI: "resource://specialpowers/AppTestDelegateParent.sys.mjs",
},
child: {
moduleURI: "resource://specialpowers/AppTestDelegateChild.jsm",
esModuleURI: "resource://specialpowers/AppTestDelegateChild.sys.mjs",
events: {
DOMContentLoaded: { capture: true },
load: { capture: true },

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

@ -1,10 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var EXPORTED_SYMBOLS = ["AppTestDelegate"];
class Delegate {
actor(window) {
return window.windowGlobalChild.getActor("AppTestDelegate");
@ -53,4 +49,4 @@ class Delegate {
}
}
var AppTestDelegate = new Delegate();
export var AppTestDelegate = new Delegate();

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

@ -2,11 +2,7 @@
* 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/. */
"use strict";
const EXPORTED_SYMBOLS = ["AppTestDelegateChild"];
class AppTestDelegateChild extends JSWindowActorChild {
export class AppTestDelegateChild extends JSWindowActorChild {
handleEvent(event) {
switch (event.type) {
case "DOMContentLoaded":

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

@ -2,13 +2,7 @@
* 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/. */
"use strict";
const EXPORTED_SYMBOLS = ["AppTestDelegateParent"];
var { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -17,7 +11,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
AppUiTestDelegate: "resource://testing-common/AppUiTestDelegate.jsm",
});
class AppTestDelegateParent extends JSWindowActorParent {
export class AppTestDelegateParent extends JSWindowActorParent {
constructor() {
super();
this._tabs = new Map();

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

@ -2,8 +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 = ["MockColorPicker"];
const lazy = {};
ChromeUtils.defineModuleGetter(
@ -30,7 +28,7 @@ var newFactory = function(window) {
};
};
var MockColorPicker = {
export var MockColorPicker = {
init(window) {
this.reset();
this.factory = newFactory(window);

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

@ -2,8 +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 = ["MockFilePicker"];
const lazy = {};
ChromeUtils.defineModuleGetter(
@ -20,8 +18,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
});
/* globals __URI__ */
if (__URI__.includes("specialpowers")) {
if (import.meta.url.includes("specialpowers")) {
Cu.crashIfNotInAutomation();
}
@ -37,7 +34,7 @@ var newFactory = function(window) {
};
};
var MockFilePicker = {
export var MockFilePicker = {
returnOK: Ci.nsIFilePicker.returnOK,
returnCancel: Ci.nsIFilePicker.returnCancel,
returnReplace: Ci.nsIFilePicker.returnReplace,

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

@ -2,8 +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 = ["MockPermissionPrompt"];
const Cm = Components.manager;
const CONTRACT_ID = "@mozilla.org/content-permission/prompt;1";
@ -18,7 +16,7 @@ var newFactory = {
QueryInterface: ChromeUtils.generateQI(["nsIFactory"]),
};
var MockPermissionPrompt = {
export var MockPermissionPrompt = {
init() {
this.reset();
if (!registrar.isCIDRegistered(newClassID)) {

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

@ -4,10 +4,6 @@
/* This code is loaded in every child process that is started by mochitest.
*/
"use strict";
var EXPORTED_SYMBOLS = ["SpecialPowersChild"];
const { ExtensionUtils } = ChromeUtils.import(
"resource://gre/modules/ExtensionUtils.jsm"
);
@ -47,9 +43,8 @@ ChromeUtils.defineModuleGetter(
"NetUtil",
"resource://gre/modules/NetUtil.jsm"
);
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
ChromeUtils.defineModuleGetter(
lazy,
"PerTestCoverageUtils",
@ -151,7 +146,7 @@ SPConsoleListener.prototype = {
QueryInterface: ChromeUtils.generateQI(["nsIConsoleListener", "nsIObserver"]),
};
class SpecialPowersChild extends JSWindowActorChild {
export class SpecialPowersChild extends JSWindowActorChild {
constructor() {
super();

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

@ -2,21 +2,16 @@
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["EventUtils"];
/**
* Loads a stub copy of EventUtils.js which can be used by things like
* content tasks without holding any direct references to windows.
*/
let EventUtils = {};
import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
export let EventUtils = { setTimeout, window: {}, _EU_Ci: Ci, _EU_Cc: Cc };
EventUtils.window = {};
EventUtils.parent = EventUtils.window;
EventUtils._EU_Ci = Ci;
EventUtils._EU_Cc = Cc;
EventUtils.synthesizeClick = element =>
new Promise(resolve => {

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

@ -2,16 +2,8 @@
* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["SpecialPowersParent"];
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
var { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -121,7 +113,7 @@ let nextTaskID = 1;
// window without a test harness.
let defaultAssertHandler;
class SpecialPowersParent extends JSWindowActorParent {
export class SpecialPowersParent extends JSWindowActorParent {
constructor() {
super();

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

@ -10,8 +10,6 @@
* results back to the caller.
*/
var EXPORTED_SYMBOLS = ["SpecialPowersSandbox"];
const lazy = {};
ChromeUtils.defineModuleGetter(
@ -45,7 +43,7 @@ function expectingFail(fn) {
}
}
class SpecialPowersSandbox {
export class SpecialPowersSandbox {
constructor(name, reportCallback, opts = {}) {
this.name = name;
this.reportCallback = reportCallback;

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

@ -1,7 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
/**
* This module handles wrapping privileged objects so that they can be exposed
@ -17,8 +16,6 @@
Cu.crashIfNotInAutomation();
var EXPORTED_SYMBOLS = ["WrapPrivileged"];
let wrappedObjects = new WeakMap();
let perWindowInfo = new WeakMap();
let noAutoWrap = new WeakSet();
@ -373,7 +370,7 @@ function disableAutoWrap(...objs) {
objs.forEach(x => noAutoWrap.add(x));
}
var WrapPrivileged = {
export var WrapPrivileged = {
wrap: wrapIfUnwrapped,
unwrap: unwrapIfWrapped,

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

@ -15,22 +15,22 @@ FINAL_TARGET_FILES += [
]
FINAL_TARGET_FILES.content += [
"../modules/Assert.jsm",
"content/AppTestDelegate.jsm",
"content/AppTestDelegateChild.jsm",
"content/AppTestDelegateParent.jsm",
"content/MockColorPicker.jsm",
"content/MockFilePicker.jsm",
"content/MockPermissionPrompt.jsm",
"content/SpecialPowersChild.jsm",
"content/SpecialPowersEventUtils.jsm",
"content/SpecialPowersParent.jsm",
"content/SpecialPowersSandbox.jsm",
"content/WrapPrivileged.jsm",
"../modules/Assert.sys.mjs",
"content/AppTestDelegate.sys.mjs",
"content/AppTestDelegateChild.sys.mjs",
"content/AppTestDelegateParent.sys.mjs",
"content/MockColorPicker.sys.mjs",
"content/MockFilePicker.sys.mjs",
"content/MockPermissionPrompt.sys.mjs",
"content/SpecialPowersChild.sys.mjs",
"content/SpecialPowersEventUtils.sys.mjs",
"content/SpecialPowersParent.sys.mjs",
"content/SpecialPowersSandbox.sys.mjs",
"content/WrapPrivileged.sys.mjs",
]
TESTING_JS_MODULES += [
"content/MockFilePicker.jsm",
"content/MockFilePicker.sys.mjs",
]
with Files("**"):

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

@ -2,11 +2,8 @@
* 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/. */
/* globals __URI__ */
// Module used by test_import_module.js
const EXPORTED_SYMBOLS = ["MODULE_IMPORTED", "MODULE_URI"];
export const MODULE_IMPORTED = true;
const MODULE_IMPORTED = true;
const MODULE_URI = __URI__;
export const MODULE_URI = import.meta.url;

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

@ -4,8 +4,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/. */
/* import-globals-from import_module.jsm */
/**
* Ensures that tests can import a module in the same folder through:
* ChromeUtils.import("resource://test/module.jsm");
@ -14,8 +12,8 @@
function run_test() {
Assert.ok(typeof this.MODULE_IMPORTED == "undefined");
Assert.ok(typeof this.MODULE_URI == "undefined");
let uri = "resource://test/import_module.jsm";
let exports = ChromeUtils.import(uri);
let uri = "resource://test/import_module.sys.mjs";
let exports = ChromeUtils.importESModule(uri);
Assert.ok(exports.MODULE_URI == uri);
Assert.ok(exports.MODULE_IMPORTED);
}

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

@ -7,7 +7,7 @@ head =
support-files =
subdir/file.txt
file.txt
import_module.jsm
import_module.sys.mjs
load_subscript.js
location_load.js
check_profile.js

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

@ -10,6 +10,9 @@ const { Preferences } = ChromeUtils.importESModule(
const { ContentTaskUtils } = ChromeUtils.import(
"resource://testing-common/ContentTaskUtils.jsm"
);
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
var EXPORTED_SYMBOLS = ["NarrateTestUtils"];
@ -87,6 +90,7 @@ var NarrateTestUtils = {
_EU_Ci: Ci,
_EU_Cc: Cc,
window,
setTimeout,
parent: window,
navigator: window.navigator,
KeyboardEvent: window.KeyboardEvent,

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

@ -324,7 +324,6 @@ avoid-blacklist-and-whitelist:
- testing/profiles/unittest-required/user.js
- testing/raptor/browsertime/browsertime_scenario.js
- testing/raptor/raptor/control_server.py
- testing/specialpowers/content/SpecialPowersChild.jsm
- testing/talos/talos/tests/devtools/addon/content/pages/custom/debugger/static/js/main.js
- testing/talos/talos/tests/devtools/addon/content/tests/source-map/angular-min.js.map
- testing/web-platform/tests/common/security-features/README.md