Bug 1829614 - Convert dom/console to ES modules. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D178060
This commit is contained in:
Karandeep 2023-05-23 16:19:06 +00:00
parent 729b189a97
commit e5d005787c
7 changed files with 11 additions and 17 deletions

View File

@ -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/. */
"use strict";
const STORAGE_MAX_EVENTS = 1000;
var _consoleStorage = new Map();
@ -40,7 +38,7 @@ const CONSOLEAPISTORAGE_CID = Components.ID(
* // Clear the events for the given inner window ID.
* ConsoleAPIStorage.clearEvents(innerWindowID);
*/
function ConsoleAPIStorageService() {
export function ConsoleAPIStorageService() {
this.init();
}
@ -195,5 +193,3 @@ ConsoleAPIStorageService.prototype = {
}
},
};
var EXPORTED_SYMBOLS = ["ConsoleAPIStorageService"];

View File

@ -8,7 +8,7 @@ Classes = [
{
'cid': '{96cf7855-dfa9-4c6d-8276-f9705b4890f2}',
'contract_ids': ['@mozilla.org/consoleAPI-storage;1'],
'jsm': 'resource://gre/modules/ConsoleAPIStorage.jsm',
'esModule': 'resource://gre/modules/ConsoleAPIStorage.sys.mjs',
'constructor': 'ConsoleAPIStorageService',
},
]

View File

@ -35,7 +35,7 @@ UNIFIED_SOURCES += [
]
EXTRA_JS_MODULES += [
"ConsoleAPIStorage.jsm",
"ConsoleAPIStorage.sys.mjs",
]
XPCOM_MANIFESTS += [

View File

@ -2,7 +2,7 @@
skip-if = os == 'android'
support-files =
file_empty.html
console.jsm
console.sys.mjs
head.js
[test_console.xhtml]

View File

@ -2,9 +2,7 @@
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var EXPORTED_SYMBOLS = ["ConsoleTest"];
var ConsoleTest = {
export var ConsoleTest = {
go(dumpFunction) {
console.log("Hello world!");
console.createInstance().log("Hello world!");

View File

@ -3,7 +3,7 @@
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<window title="Console + JSM"
<window title="Console + MJS"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
@ -14,7 +14,7 @@
<script type="application/javascript">
<![CDATA[
const JSM = "chrome://mochitests/content/chrome/dom/console/tests/console.jsm";
const MJS = "chrome://mochitests/content/chrome/dom/console/tests/console.sys.mjs";
let dumpCalled = 0;
function dumpFunction(msg) {
@ -30,9 +30,9 @@ function promiseConsoleListenerCalled() {
observe: function(aSubject) {
var obj = aSubject.wrappedJSObject;
ok(obj.chromeContext, "JSM is always a chrome context");
ok(obj.chromeContext, "MJS is always a chrome context");
if (obj.innerID == JSM) {
if (obj.innerID == MJS) {
is(obj.ID, "jsm", "ID and InnerID are correctly set.");
is(obj.arguments[0], "Hello world!", "Message matches");
is(obj.consoleID, "", "No consoleID for console API");
@ -79,7 +79,7 @@ async function test() {
SimpleTest.waitForExplicitFinish();
let consolePromise = promiseConsoleListenerCalled();
let { ConsoleTest } = ChromeUtils.import(JSM);
let { ConsoleTest } = ChromeUtils.importESModule(MJS);
await SpecialPowers.pushPrefEnv({set: [["pref.test.console", "log"]]})
ConsoleTest.go(dumpFunction);

View File

@ -105,7 +105,7 @@ const backgroundtaskPhases = {
// We have a profile marker for this, even though it failed to load!
"resource:///modules/backgroundtasks/BackgroundTask_wait.sys.mjs",
"resource://gre/modules/ConsoleAPIStorage.jsm",
"resource://gre/modules/ConsoleAPIStorage.sys.mjs",
"resource://gre/modules/Timer.sys.mjs",
// We have a profile marker for this, even though it failed to load!