Bug 1830816 - Convert JSMs in browser/tools/mozscreenshots/mozscreenshots/extension to ESMs. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D177101
This commit is contained in:
Katherine Patenio 2023-05-08 20:11:13 +00:00
parent a7b4318c2e
commit 6ca3f42793
22 changed files with 62 additions and 155 deletions

View File

@ -699,7 +699,7 @@ module.exports = {
"browser/base/content/test/sanitize/browser_sanitize-history.js",
"devtools/client/shared/test/shared-head.js",
"devtools/client/shared/test/head.js",
"browser/tools/mozscreenshots/mozscreenshots/extension/configurations/ControlCenter.jsm",
"browser/tools/mozscreenshots/mozscreenshots/extension/configurations/ControlCenter.sys.mjs",
// uses new HttpServer which doesn't support https
"browser/base/content/test/favicons/browser_favicon_nostore.js",
// That are all files that produes warnings in the existing test infrastructure.

View File

@ -33,8 +33,9 @@ async function setup() {
let aAddon = await AddonManager.getAddonByID("mozscreenshots@mozilla.org");
isnot(aAddon, null, "The mozscreenshots extension should be installed");
TestRunner = ChromeUtils.import("resource://mozscreenshots/TestRunner.jsm")
.TestRunner;
TestRunner = ChromeUtils.importESModule(
"resource://mozscreenshots/TestRunner.sys.mjs"
).TestRunner;
TestRunner.initTest(this);
}

View File

@ -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 = ["Screenshot"];
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
// Create a new instance of the ConsoleAPI so we can control the maxLogLevel with a pref.
// See LOG_LEVELS in Console.sys.mjs. Common examples: "All", "Info", "Warn", &
@ -30,7 +22,7 @@ XPCOMUtils.defineLazyGetter(lazy, "log", () => {
return new ConsoleAPI(consoleOptions);
});
var Screenshot = {
export var Screenshot = {
_extensionPath: null,
_path: null,
_imagePrefix: "",

View File

@ -2,36 +2,22 @@
* 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 = ["TestRunner"];
const APPLY_CONFIG_TIMEOUT_MS = 60 * 1000;
const HOME_PAGE = "resource://mozscreenshots/lib/mozscreenshots.html";
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
const { Rect } = ChromeUtils.importESModule(
"resource://gre/modules/Geometry.sys.mjs"
);
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
import { Rect } from "resource://gre/modules/Geometry.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
BrowserTestUtils: "resource://testing-common/BrowserTestUtils.sys.mjs",
// Screenshot.sys.mjs must be imported this way for xpcshell tests to work
Screenshot: "resource://mozscreenshots/Screenshot.sys.mjs",
});
// Screenshot.jsm must be imported this way for xpcshell tests to work
ChromeUtils.defineModuleGetter(
lazy,
"Screenshot",
"resource://mozscreenshots/Screenshot.jsm"
);
var TestRunner = {
export var TestRunner = {
combos: null,
completedCombos: 0,
currentComboIndex: 0,

View File

@ -18,8 +18,8 @@ this.mozscreenshots = class extends ExtensionAPI {
let uri = Services.io.newURI("resources/", null, this.extension.rootURI);
resProto.setSubstitution("mozscreenshots", uri);
const { TestRunner } = ChromeUtils.import(
"resource://mozscreenshots/TestRunner.jsm"
const { TestRunner } = ChromeUtils.importESModule(
"resource://mozscreenshots/TestRunner.sys.mjs"
);
TestRunner.init(this.extension.rootURI);
}

View File

@ -2,15 +2,9 @@
* 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 { BrowserTestUtils } from "resource://testing-common/BrowserTestUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["AppMenu"];
const { BrowserTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/BrowserTestUtils.sys.mjs"
);
var AppMenu = {
export var AppMenu = {
init(libDir) {},
configurations: {

View File

@ -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 = ["Buttons"];
const { CustomizableUI } = ChromeUtils.import(
"resource:///modules/CustomizableUI.jsm"
);
var Buttons = {
export var Buttons = {
init(libDir) {
createWidget();
},

View File

@ -2,23 +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/. */
"use strict";
import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
import { BrowserTestUtils } from "resource://testing-common/BrowserTestUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["ControlCenter"];
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
const { BrowserTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/BrowserTestUtils.sys.mjs"
);
const { SitePermissions } = ChromeUtils.import(
"resource:///modules/SitePermissions.jsm"
);
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
let { UrlClassifierTestUtils } = ChromeUtils.import(
"resource://testing-common/UrlClassifierTestUtils.jsm"
@ -38,7 +29,7 @@ const MIXED_ACTIVE_CONTENT_URL = `https://example.com/${RESOURCE_PATH}/mixed_act
const MIXED_PASSIVE_CONTENT_URL = `https://example.com/${RESOURCE_PATH}/mixed_passive.html`;
const TRACKING_PAGE = `http://tracking.example.org/${RESOURCE_PATH}/tracking.html`;
var ControlCenter = {
export var ControlCenter = {
init(libDir) {},
configurations: {

View File

@ -2,15 +2,9 @@
* 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 { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
var EXPORTED_SYMBOLS = ["CustomizeMode"];
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
var CustomizeMode = {
export var CustomizeMode = {
init(libDir) {},
configurations: {

View File

@ -2,17 +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";
import { require } from "resource://devtools/shared/loader/Loader.sys.mjs";
var EXPORTED_SYMBOLS = ["DevTools"];
const { require } = ChromeUtils.importESModule(
"resource://devtools/shared/loader/Loader.sys.mjs"
);
const { gDevTools } = require("devtools/client/framework/devtools");
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
async function showToolboxForSelectedTab(toolId, hostType) {
const browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
@ -24,7 +18,7 @@ function selectToolbox(toolbox) {
return toolbox.win.document.querySelector("#toolbox-container");
}
var DevTools = {
export var DevTools = {
init(libDir) {
let panels = [
"options",

View File

@ -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 = ["LightweightThemes"];
const { AddonManager } = ChromeUtils.import(
"resource://gre/modules/AddonManager.jsm"
);
var LightweightThemes = {
export var LightweightThemes = {
init(libDir) {},
configurations: {

View File

@ -2,22 +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";
// Various parts here are run in the content process.
/* global content */
var EXPORTED_SYMBOLS = ["PermissionPrompts"];
const { BrowserTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/BrowserTestUtils.sys.mjs"
);
import { BrowserTestUtils } from "resource://testing-common/BrowserTestUtils.sys.mjs";
const URL =
"https://test1.example.com/browser/browser/tools/mozscreenshots/mozscreenshots/extension/mozscreenshots/browser/resources/lib/permissionPrompts.html";
let lastTab = null;
var PermissionPrompts = {
export var PermissionPrompts = {
init(libDir) {
Services.prefs.setBoolPref("media.navigator.permission.fake", true);
Services.prefs.setBoolPref("extensions.install.requireBuiltInCerts", false);

View File

@ -2,17 +2,12 @@
* 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";
// Various parts here are run in the content process.
/* global content */
var EXPORTED_SYMBOLS = ["Preferences"];
import { TestUtils } from "resource://testing-common/TestUtils.sys.mjs";
const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
var Preferences = {
export var Preferences = {
init(libDir) {
let panes = [
["paneGeneral"],

View File

@ -2,22 +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/. */
"use strict";
var EXPORTED_SYMBOLS = ["Tabs"];
const CUST_TAB = "chrome://browser/skin/customize.svg";
const PREFS_TAB = "chrome://global/skin/icons/settings.svg";
const DEFAULT_FAVICON_TAB = `data:text/html,<meta%20charset="utf-8"><title>No%20favicon</title>`;
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
import { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
import { TestUtils } from "resource://testing-common/TestUtils.sys.mjs";
var Tabs = {
export var Tabs = {
init(libDir) {},
configurations: {

View File

@ -2,13 +2,9 @@
* 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 = ["TabsInTitlebar"];
const PREF_TABS_IN_TITLEBAR = "browser.tabs.inTitlebar";
var TabsInTitlebar = {
export var TabsInTitlebar = {
init(libDir) {},
configurations: {

View File

@ -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";
var EXPORTED_SYMBOLS = ["Toolbars"];
var Toolbars = {
export var Toolbars = {
init(libDir) {},
configurations: {

View File

@ -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";
var EXPORTED_SYMBOLS = ["UIDensities"];
var UIDensities = {
export var UIDensities = {
init(libDir) {},
configurations: {

View File

@ -2,18 +2,10 @@
* 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 { setTimeout } from "resource://gre/modules/Timer.sys.mjs";
import { BrowserTestUtils } from "resource://testing-common/BrowserTestUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["WindowSize"];
const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
const { BrowserTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/BrowserTestUtils.sys.mjs"
);
var WindowSize = {
export var WindowSize = {
init(libDir) {
Services.prefs.setBoolPref("browser.fullscreen.autohide", false);
},

View File

@ -15,24 +15,24 @@ FINAL_TARGET_FILES += [
]
FINAL_TARGET_FILES.resources += [
"Screenshot.jsm",
"TestRunner.jsm",
"Screenshot.sys.mjs",
"TestRunner.sys.mjs",
]
FINAL_TARGET_FILES.resources.configurations += [
"configurations/AppMenu.jsm",
"configurations/Buttons.jsm",
"configurations/ControlCenter.jsm",
"configurations/CustomizeMode.jsm",
"configurations/DevTools.jsm",
"configurations/LightweightThemes.jsm",
"configurations/PermissionPrompts.jsm",
"configurations/Preferences.jsm",
"configurations/Tabs.jsm",
"configurations/TabsInTitlebar.jsm",
"configurations/Toolbars.jsm",
"configurations/UIDensities.jsm",
"configurations/WindowSize.jsm",
"configurations/AppMenu.sys.mjs",
"configurations/Buttons.sys.mjs",
"configurations/ControlCenter.sys.mjs",
"configurations/CustomizeMode.sys.mjs",
"configurations/DevTools.sys.mjs",
"configurations/LightweightThemes.sys.mjs",
"configurations/PermissionPrompts.sys.mjs",
"configurations/Preferences.sys.mjs",
"configurations/Tabs.sys.mjs",
"configurations/TabsInTitlebar.sys.mjs",
"configurations/Toolbars.sys.mjs",
"configurations/UIDensities.sys.mjs",
"configurations/WindowSize.sys.mjs",
]
FINAL_TARGET_FILES.resources.lib += [

View File

@ -4,7 +4,9 @@
"use strict";
const { TestRunner } = ChromeUtils.import("resource://test/TestRunner.jsm");
const { TestRunner } = ChromeUtils.importESModule(
"resource://test/TestRunner.sys.mjs"
);
add_task(async function capture() {
equal(TestRunner.findComma("Toolbars,Devs"), 8);

View File

@ -1,5 +1,5 @@
[DEFAULT]
skip-if = toolkit == 'android' # bug 1730213
support-files = ../../mozscreenshots/extension/TestRunner.jsm
support-files = ../../mozscreenshots/extension/TestRunner.sys.mjs
[test_testConfigurations.js]

View File

@ -68,7 +68,7 @@ avoid-blacklist-and-whitelist:
- browser/extensions/screenshots/background/main.js
- browser/extensions/webcompat/shims/nielsen.js
- browser/modules/SitePermissions.jsm
- browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm
- browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.sys.mjs
- build/clang-plugin/CustomMatchers.h
- build/clang-plugin/FopenUsageChecker.cpp
- build/clang-plugin/NaNExprChecker.cpp