Bug 1808173 - Convert toolkit/components/prompts to ES modules. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D165793
This commit is contained in:
Mark Banner 2023-01-16 13:32:20 +00:00
Родитель f35ab1379d
Коммит e9868a28ce
8 изменённых файлов: 18 добавлений и 46 удалений

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

@ -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 { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
var EXPORTED_SYMBOLS = ["TabModalPrompt"];
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
var TabModalPrompt = class {
export var TabModalPrompt = class {
constructor(win) {
this.win = win;
let newPrompt = (this.element = win.document.createElement(

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

@ -10,4 +10,4 @@ toolkit.jar:
content/global/selectDialog.js (content/selectDialog.js)
content/global/selectDialog.xhtml (content/selectDialog.xhtml)
content/global/tabprompts.css (content/tabprompts.css)
content/global/tabprompts.jsm (content/tabprompts.jsm)
content/global/tabprompts.sys.mjs (content/tabprompts.sys.mjs)

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

@ -15,7 +15,7 @@ with Files("docs/**"):
SCHEDULES.exclusive = ["docs"]
TESTING_JS_MODULES += [
"test/PromptTestUtils.jsm",
"test/PromptTestUtils.sys.mjs",
]
MOCHITEST_MANIFESTS += ["test/mochitest.ini"]

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

@ -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/. */
var EXPORTED_SYMBOLS = ["CommonDialog"];
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
EnableDelayHelper: "resource://gre/modules/PromptUtils.sys.mjs",
});
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
function CommonDialog(args, ui) {
export function CommonDialog(args, ui) {
this.args = args;
this.ui = ui;
this.initialFocusPromise = new Promise(resolve => {

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

@ -2,15 +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 { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
// This is redefined below, for strange and unfortunate reasons.
var { PromptUtils } = ChromeUtils.importESModule(
"resource://gre/modules/PromptUtils.sys.mjs"
);
import { PromptUtils } from "resource://gre/modules/PromptUtils.sys.mjs";
const {
MODAL_TYPE_TAB,
@ -22,7 +17,7 @@ const {
const COMMON_DIALOG = "chrome://global/content/commonDialog.xhtml";
const SELECT_DIALOG = "chrome://global/content/selectDialog.xhtml";
function Prompter() {
export function Prompter() {
// Note that EmbedPrompter clones this implementation.
}
@ -1733,7 +1728,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
false
);
function AuthPromptAdapterFactory() {}
export function AuthPromptAdapterFactory() {}
AuthPromptAdapterFactory.prototype = {
classID: Components.ID("{6e134924-6c3a-4d86-81ac-69432dd971dc}"),
QueryInterface: ChromeUtils.generateQI(["nsIAuthPromptAdapterFactory"]),
@ -1814,5 +1809,3 @@ AuthPromptAdapter.prototype = {
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
},
};
var EXPORTED_SYMBOLS = ["Prompter", "AuthPromptAdapterFactory"];

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

@ -8,7 +8,7 @@ Classes = [
{
'cid': '{6e134924-6c3a-4d86-81ac-69432dd971dc}',
'contract_ids': ['@mozilla.org/network/authprompt-adapter-factory;1'],
'jsm': 'resource://gre/modules/Prompter.jsm',
'esModule': 'resource://gre/modules/Prompter.sys.mjs',
'constructor': 'AuthPromptAdapterFactory',
},
]
@ -20,7 +20,7 @@ if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] != 'android':
'cid': '{1c978d25-b37f-43a8-a2d6-0c7a239ead87}',
'contract_ids': ['@mozilla.org/prompter;1'],
'interfaces': ['nsIPromptService'],
'jsm': 'resource://gre/modules/Prompter.jsm',
'esModule': 'resource://gre/modules/Prompter.sys.mjs',
'constructor': 'Prompter',
},
]

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

@ -5,8 +5,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES += [
"CommonDialog.jsm",
"Prompter.jsm",
"CommonDialog.sys.mjs",
"Prompter.sys.mjs",
"PromptUtils.sys.mjs",
]

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

@ -6,20 +6,9 @@
* nsIPromptService.
*/
"use strict";
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { BrowserTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/BrowserTestUtils.sys.mjs"
);
const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
const EXPORTED_SYMBOLS = ["PromptTestUtils"];
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { BrowserTestUtils } from "resource://testing-common/BrowserTestUtils.sys.mjs";
import { TestUtils } from "resource://testing-common/TestUtils.sys.mjs";
const kPrefs = {};
@ -51,7 +40,7 @@ function isCommonDialog(modalType) {
);
}
let PromptTestUtils = {
export let PromptTestUtils = {
/**
* Wait for a prompt from nsIPrompt or nsIPromptsService, interact with it and
* click the specified button to close it.