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_dynUnsecurePicture.html",
"security/manager/ssl/tests/mochitest/mixedcontent/test_dynUnsecurePicturePreload.html", "security/manager/ssl/tests/mochitest/mixedcontent/test_dynUnsecurePicturePreload.html",
"security/sandbox/test/browser_bug1393259.js", "security/sandbox/test/browser_bug1393259.js",
"testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm ",
"testing/mochitest/chrome/test_sanityEventUtils.xhtml", "testing/mochitest/chrome/test_sanityEventUtils.xhtml",
"testing/mochitest/server.js", "testing/mochitest/server.js",
"testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html", "testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html",

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

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

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

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

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

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

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

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

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

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

@ -34,7 +34,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1560741
}); });
let checkRequest = async (expectedResponse, msg) => { let checkRequest = async (expectedResponse, msg) => {
/* import-globals-from ../../../../testing/modules/Assert.jsm */
let response = await this.content.Notification.requestPermission(); let response = await this.content.Notification.requestPermission();
Assert.equal(response, expectedResponse, msg); Assert.equal(response, expectedResponse, msg);
}; };
@ -44,7 +43,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1560741
checkRequest); checkRequest);
let checkPermission = async (expectedPermission, msg) => { let checkPermission = async (expectedPermission, msg) => {
/* import-globals-from ../../../../testing/modules/Assert.jsm */
let permission = this.content.Notification.permission; let permission = this.content.Notification.permission;
Assert.equal(permission, expectedPermission, msg); 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.setAttribute("src", "https://example.org/tests/dom/security/featurePolicy/test/mochitest/empty.html");
ifr.onload = async function() { ifr.onload = async function() {
await SpecialPowers.spawn(ifr, [], () => { 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("featurePolicy" in this.content.document, "We have this.content.document.featurePolicy");
Assert.ok(!this.content.document.featurePolicy.allowsFeature("foobar"), "Random feature"); 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 convention, and in addition to mochitest assertions supports the
[CommonJS standard assertions](http://wiki.commonjs.org/wiki/Unit_Testing/1.1), [CommonJS standard assertions](http://wiki.commonjs.org/wiki/Unit_Testing/1.1),
like [nodejs' assert module](https://nodejs.org/api/assert.html#assert) but 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 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 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. file to share JS code.
Where code is needed across various directories of tests, you should consider if it's 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 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 `TESTING_JS_MODULES` in `moz.build` to avoid packaging them with Firefox. They
will be available in `resource://testing-common/` to all tests. will be available in `resource://testing-common/` to all tests.

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

@ -12,19 +12,13 @@
// This file uses ContentTask & frame scripts, where these are available. // This file uses ContentTask & frame scripts, where these are available.
/* global ContentTaskUtils */ /* 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( const { ComponentUtils } = ChromeUtils.import(
"resource://gre/modules/ComponentUtils.jsm" "resource://gre/modules/ComponentUtils.jsm"
); );
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { TestUtils } = ChromeUtils.import( const { TestUtils } = ChromeUtils.import(
"resource://testing-common/TestUtils.jsm" "resource://testing-common/TestUtils.jsm"
); );
@ -82,10 +76,10 @@ const kAboutPageRegistrationContentScript =
function registerActors() { function registerActors() {
ChromeUtils.registerWindowActor("BrowserTestUtils", { ChromeUtils.registerWindowActor("BrowserTestUtils", {
parent: { parent: {
moduleURI: "resource://testing-common/BrowserTestUtilsParent.jsm", esModuleURI: "resource://testing-common/BrowserTestUtilsParent.sys.mjs",
}, },
child: { child: {
moduleURI: "resource://testing-common/BrowserTestUtilsChild.jsm", esModuleURI: "resource://testing-common/BrowserTestUtilsChild.sys.mjs",
events: { events: {
DOMContentLoaded: { capture: true }, DOMContentLoaded: { capture: true },
load: { capture: true }, load: { capture: true },
@ -97,10 +91,12 @@ function registerActors() {
ChromeUtils.registerWindowActor("ContentEventListener", { ChromeUtils.registerWindowActor("ContentEventListener", {
parent: { parent: {
moduleURI: "resource://testing-common/ContentEventListenerParent.jsm", esModuleURI:
"resource://testing-common/ContentEventListenerParent.sys.mjs",
}, },
child: { child: {
moduleURI: "resource://testing-common/ContentEventListenerChild.jsm", esModuleURI:
"resource://testing-common/ContentEventListenerChild.sys.mjs",
events: { events: {
// We need to see the creation of all new windows, in case they have // We need to see the creation of all new windows, in case they have
// a browsing context we are interested in. // a browsing context we are interested in.
@ -122,7 +118,7 @@ registerActors();
* *
* @class * @class
*/ */
var BrowserTestUtils = { export var BrowserTestUtils = {
/** /**
* Loads a page in a new tab, executes a Task and closes the tab. * 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 /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["BrowserTestUtilsChild"];
const lazy = {}; const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
@ -104,7 +101,7 @@ BrowserTestUtilsChildObserver.prototype.QueryInterface = ChromeUtils.generateQI(
["nsIObserver", "nsISupportsWeakReference"] ["nsIObserver", "nsISupportsWeakReference"]
); );
class BrowserTestUtilsChild extends JSWindowActorChild { export class BrowserTestUtilsChild extends JSWindowActorChild {
actorCreated() { actorCreated() {
this._EventUtils = null; this._EventUtils = null;
} }

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

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

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

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

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

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

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

@ -4,10 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * 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"; const FRAME_SCRIPT = "resource://testing-common/content-task.js";
/** /**
@ -28,7 +24,7 @@ var gMessageID = 1;
/** /**
* This object provides the public module functions. * This object provides the public module functions.
*/ */
var ContentTask = { export var ContentTask = {
/** /**
* _testScope saves the current testScope from * _testScope saves the current testScope from
* browser-test.js. This is used to implement SimpleTest functions * browser-test.js. This is used to implement SimpleTest functions

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

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

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

@ -12,19 +12,22 @@ let { ContentTaskUtils } = ChromeUtils.import(
const { Assert: AssertCls } = ChromeUtils.import( const { Assert: AssertCls } = ChromeUtils.import(
"resource://testing-common/Assert.jsm" "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 // 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 // to the window global. This means you **need** to pass the window as an argument to
// the individual EventUtils functions. // the individual EventUtils functions.
// See SimpleTest/EventUtils.js for documentation. // See SimpleTest/EventUtils.js for documentation.
var EventUtils = {}; var EventUtils = {
_EU_Ci: Ci,
EventUtils.window = {}; _EU_Cc: Cc,
EventUtils.parent = EventUtils.window; KeyboardEvent: content.KeyboardEvent,
EventUtils._EU_Ci = Ci; navigator: content.navigator,
EventUtils._EU_Cc = Cc; setTimeout,
EventUtils.KeyboardEvent = content.KeyboardEvent; window: {},
EventUtils.navigator = content.navigator; };
EventUtils.synthesizeClick = element => EventUtils.synthesizeClick = element =>
new Promise(resolve => { new Promise(resolve => {

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

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

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

@ -2,18 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
const { setTimeout } = ChromeUtils.importESModule( import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
"resource://gre/modules/Timer.sys.mjs"
);
var EXPORTED_SYMBOLS = ["ContentCollector"];
// This listens for the message "browser-test:collect-request". When it gets it, // 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 // 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 // are complete. Mochitest uses this information to determine when windows and
// docshells should be destroyed. // docshells should be destroyed.
var ContentCollector = { export var ContentCollector = {
init() { init() {
let processType = Services.appinfo.processType; let processType = Services.appinfo.processType;
if (processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) { if (processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
@ -61,4 +57,5 @@ var ContentCollector = {
Services.cpmm.removeMessageListener("browser-test:collect-request", this); Services.cpmm.removeMessageListener("browser-test:collect-request", this);
}, },
}; };
ContentCollector.init(); ContentCollector.init();

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

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

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

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

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

@ -2,10 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["makeFakeAppDir"];
/* global OS */ /* global OS */
Cc["@mozilla.org/net/osfileconstantsservice;1"] Cc["@mozilla.org/net/osfileconstantsservice;1"]
.getService(Ci.nsIOSFileConstantsService) .getService(Ci.nsIOSFileConstantsService)
@ -27,7 +23,7 @@ var gFakeAppDirectoryProvider;
* This returns a promise that will be resolved once the new directory * This returns a promise that will be resolved once the new directory
* is created and installed. * is created and installed.
*/ */
var makeFakeAppDir = function() { export var makeFakeAppDir = function() {
let dirMode = OS.Constants.libc.S_IRWXU; let dirMode = OS.Constants.libc.S_IRWXU;
let baseFile = Services.dirsvc.get("ProfD", Ci.nsIFile); let baseFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
let appD = baseFile.clone(); let appD = baseFile.clone();

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

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

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

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

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

@ -2,21 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 // eslint-disable-next-line mozilla/reject-globalThis-modification
addDebuggerToGlobal(globalThis); addDebuggerToGlobal(globalThis);
/** /**
* Records coverage for each test by way of the js debugger. * Records coverage for each test by way of the js debugger.
*/ */
var CoverageCollector = function(prefix) { export var CoverageCollector = function(prefix) {
this._prefix = prefix; this._prefix = prefix;
this._dbg = new Debugger(); this._dbg = new Debugger();
this._dbg.collectCoverageInfo = true; this._dbg.collectCoverageInfo = true;

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

@ -6,25 +6,16 @@
* Provides testing functions dealing with local files and their contents. * 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"); const { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm");
let gFileCounter = 1; let gFileCounter = 1;
let gPathsToRemove = []; let gPathsToRemove = [];
var FileTestUtils = { export var FileTestUtils = {
/** /**
* Returns a reference to a temporary file that is guaranteed not to exist and * 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 * 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["MockRegistrar"];
const Cm = Components.manager; const Cm = Components.manager;
const { Log } = ChromeUtils.importESModule( import { Log } from "resource://gre/modules/Log.sys.mjs";
"resource://gre/modules/Log.sys.mjs"
);
var logger = Log.repository.getLogger("MockRegistrar"); var logger = Log.repository.getLogger("MockRegistrar");
var MockRegistrar = Object.freeze({ export var MockRegistrar = Object.freeze({
_registeredComponents: new Map(), _registeredComponents: new Map(),
_originalCIDs: new Map(), _originalCIDs: new Map(),
get registrar() { get registrar() {

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

@ -2,15 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["MockRegistry"];
const { MockRegistrar } = ChromeUtils.import( const { MockRegistrar } = ChromeUtils.import(
"resource://testing-common/MockRegistrar.jsm" "resource://testing-common/MockRegistrar.jsm"
); );
class MockRegistry { export class MockRegistry {
constructor() { constructor() {
// Three level structure of Maps pointing to Maps pointing to Maps // Three level structure of Maps pointing to Maps pointing to Maps
// this.roots is the top of the structure and has ROOT_KEY_* values // this.roots is the top of the structure and has ROOT_KEY_* values

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

@ -16,13 +16,8 @@
* example LoginTestUtils.jsm. * 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( const ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(
Ci.nsIConsoleAPIStorage Ci.nsIConsoleAPIStorage
); );
@ -33,7 +28,7 @@ const ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(
* *
* @class * @class
*/ */
var TestUtils = { export var TestUtils = {
executeSoon(callbackFn) { executeSoon(callbackFn) {
Services.tm.dispatchToMainThread(callbackFn); Services.tm.dispatchToMainThread(callbackFn);
}, },

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

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

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

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

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

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

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

@ -1,10 +1,6 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */ * http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var EXPORTED_SYMBOLS = ["AppTestDelegate"];
class Delegate { class Delegate {
actor(window) { actor(window) {
return window.windowGlobalChild.getActor("AppTestDelegate"); 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; export class AppTestDelegateChild extends JSWindowActorChild {
const EXPORTED_SYMBOLS = ["AppTestDelegateChild"];
class AppTestDelegateChild extends JSWindowActorChild {
handleEvent(event) { handleEvent(event) {
switch (event.type) { switch (event.type) {
case "DOMContentLoaded": case "DOMContentLoaded":

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

@ -2,13 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const EXPORTED_SYMBOLS = ["AppTestDelegateParent"];
var { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const lazy = {}; const lazy = {};
@ -17,7 +11,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
AppUiTestDelegate: "resource://testing-common/AppUiTestDelegate.jsm", AppUiTestDelegate: "resource://testing-common/AppUiTestDelegate.jsm",
}); });
class AppTestDelegateParent extends JSWindowActorParent { export class AppTestDelegateParent extends JSWindowActorParent {
constructor() { constructor() {
super(); super();
this._tabs = new Map(); this._tabs = new Map();

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

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = ["MockColorPicker"];
const lazy = {}; const lazy = {};
ChromeUtils.defineModuleGetter( ChromeUtils.defineModuleGetter(
@ -30,7 +28,7 @@ var newFactory = function(window) {
}; };
}; };
var MockColorPicker = { export var MockColorPicker = {
init(window) { init(window) {
this.reset(); this.reset();
this.factory = newFactory(window); this.factory = newFactory(window);

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

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = ["MockFilePicker"];
const lazy = {}; const lazy = {};
ChromeUtils.defineModuleGetter( ChromeUtils.defineModuleGetter(
@ -20,8 +18,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
FileUtils: "resource://gre/modules/FileUtils.sys.mjs", FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
}); });
/* globals __URI__ */ if (import.meta.url.includes("specialpowers")) {
if (__URI__.includes("specialpowers")) {
Cu.crashIfNotInAutomation(); Cu.crashIfNotInAutomation();
} }
@ -37,7 +34,7 @@ var newFactory = function(window) {
}; };
}; };
var MockFilePicker = { export var MockFilePicker = {
returnOK: Ci.nsIFilePicker.returnOK, returnOK: Ci.nsIFilePicker.returnOK,
returnCancel: Ci.nsIFilePicker.returnCancel, returnCancel: Ci.nsIFilePicker.returnCancel,
returnReplace: Ci.nsIFilePicker.returnReplace, returnReplace: Ci.nsIFilePicker.returnReplace,

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

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = ["MockPermissionPrompt"];
const Cm = Components.manager; const Cm = Components.manager;
const CONTRACT_ID = "@mozilla.org/content-permission/prompt;1"; const CONTRACT_ID = "@mozilla.org/content-permission/prompt;1";
@ -18,7 +16,7 @@ var newFactory = {
QueryInterface: ChromeUtils.generateQI(["nsIFactory"]), QueryInterface: ChromeUtils.generateQI(["nsIFactory"]),
}; };
var MockPermissionPrompt = { export var MockPermissionPrompt = {
init() { init() {
this.reset(); this.reset();
if (!registrar.isCIDRegistered(newClassID)) { if (!registrar.isCIDRegistered(newClassID)) {

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

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

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

@ -2,21 +2,16 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 * Loads a stub copy of EventUtils.js which can be used by things like
* content tasks without holding any direct references to windows. * 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.parent = EventUtils.window;
EventUtils._EU_Ci = Ci;
EventUtils._EU_Cc = Cc;
EventUtils.synthesizeClick = element => EventUtils.synthesizeClick = element =>
new Promise(resolve => { new Promise(resolve => {

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

@ -2,16 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict"; import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["SpecialPowersParent"];
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
var { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const lazy = {}; const lazy = {};
@ -121,7 +113,7 @@ let nextTaskID = 1;
// window without a test harness. // window without a test harness.
let defaultAssertHandler; let defaultAssertHandler;
class SpecialPowersParent extends JSWindowActorParent { export class SpecialPowersParent extends JSWindowActorParent {
constructor() { constructor() {
super(); super();

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

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

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

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

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

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

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

@ -2,11 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals __URI__ */
// Module used by test_import_module.js // Module used by test_import_module.js
const EXPORTED_SYMBOLS = ["MODULE_IMPORTED", "MODULE_URI"]; export const MODULE_IMPORTED = true;
const MODULE_IMPORTED = true; export const MODULE_URI = import.meta.url;
const MODULE_URI = __URI__;

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

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

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

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

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

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

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

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