From 8fc8ec5d8e3507bc0467040a9ebd980fa4e5491b Mon Sep 17 00:00:00 2001 From: criss Date: Fri, 17 Jun 2022 05:44:37 +0300 Subject: [PATCH] Backed out 8 changesets (bug 1771092, bug 1768870, bug 1771097, bug 1769002, bug 1768819) for causing mochitest failures on browser_sendQuery.js. CLOSED TREE Backed out changeset 8a4d712f819a (bug 1771092) Backed out changeset f4e27a35c83c (bug 1771092) Backed out changeset 072323bc72cc (bug 1771092) Backed out changeset 2ccf2a00fff7 (bug 1769002) Backed out changeset ba7086fd9b1f (bug 1768819) Backed out changeset 6205d3e2c666 (bug 1771097) Backed out changeset 960f0aee97d5 (bug 1768870) Backed out changeset 5f53760c5637 (bug 1768870) --- .../static/browser_all_files_referenced.js | 4 - .../lint/linters/eslint-plugin-mozilla.rst | 1 - .../lazy-getter-object-name.rst | 25 --- dom/base/ChromeUtils.cpp | 142 +++--------------- dom/base/ChromeUtils.h | 5 - dom/chrome-webidl/ChromeUtils.webidl | 12 -- dom/chrome-webidl/JSProcessActor.webidl | 20 +-- dom/chrome-webidl/JSWindowActor.webidl | 20 +-- dom/ipc/PContent.ipdl | 9 -- dom/ipc/jsactor/JSActorManager.cpp | 23 +-- dom/ipc/jsactor/JSActorProtocolUtils.h | 117 --------------- dom/ipc/jsactor/JSActorService.h | 1 - dom/ipc/jsactor/JSProcessActorProtocol.cpp | 36 ++++- dom/ipc/jsactor/JSProcessActorProtocol.h | 3 - dom/ipc/jsactor/JSWindowActorProtocol.cpp | 40 +++-- dom/ipc/jsactor/JSWindowActorProtocol.h | 3 - dom/ipc/tests/JSProcessActor/browser.ini | 2 +- .../browser_registerProcessActor.js | 4 +- .../tests/JSProcessActor/browser_sendQuery.js | 25 +-- .../JSProcessActor/browser_uri_combination.js | 81 ---------- dom/ipc/tests/JSProcessActor/head.js | 32 +--- dom/ipc/tests/JSWindowActor/browser.ini | 1 - .../browser_registerWindowActor.js | 8 +- .../tests/JSWindowActor/browser_sendQuery.js | 26 +--- .../JSWindowActor/browser_uri_combination.js | 81 ---------- dom/ipc/tests/JSWindowActor/head.js | 29 +--- js/xpconnect/idl/xpccomponents.idl | 27 +--- js/xpconnect/loader/mozJSComponentLoader.cpp | 34 ----- js/xpconnect/loader/mozJSComponentLoader.h | 2 - js/xpconnect/src/XPCComponents.cpp | 33 +--- .../tests/unit/es6module_loaded-1.sys.mjs | 1 - .../tests/unit/es6module_loaded-2.sys.mjs | 1 - .../tests/unit/es6module_loaded-3.sys.mjs | 1 - js/xpconnect/tests/unit/esm_lazy-1.sys.mjs | 4 - js/xpconnect/tests/unit/esm_lazy-2.sys.mjs | 4 - js/xpconnect/tests/unit/jsm_loaded-1.jsm | 2 - js/xpconnect/tests/unit/jsm_loaded-2.jsm | 2 - js/xpconnect/tests/unit/jsm_loaded-3.jsm | 2 - .../tests/unit/test_defineESModuleGetters.js | 76 ---------- .../tests/unit/test_loadedESModules.js | 127 ---------------- js/xpconnect/tests/unit/xpcshell.ini | 10 -- toolkit/actors/TestProcessActorChild.sys.mjs | 60 -------- toolkit/actors/TestProcessActorParent.sys.mjs | 40 ----- toolkit/actors/TestWindowChild.sys.mjs | 103 ------------- toolkit/actors/TestWindowParent.sys.mjs | 50 ------ toolkit/actors/moz.build | 4 - ...pleServices.sys.mjs => SimpleServices.jsm} | 8 +- toolkit/components/utils/components.conf | 4 +- toolkit/components/utils/moz.build | 2 +- .../lib/configs/recommended.js | 1 - .../eslint/eslint-plugin-mozilla/lib/index.js | 1 - .../lib/rules/lazy-getter-object-name.js | 45 ------ .../tests/lazy-getter-object-name.js | 50 ------ xpcom/components/StaticComponents.cpp.in | 53 +------ xpcom/components/StaticComponents.h | 1 - xpcom/components/gen_static_components.py | 29 ---- xpcom/components/nsComponentManager.cpp | 9 -- xpcom/components/nsIComponentManager.idl | 6 - 58 files changed, 142 insertions(+), 1400 deletions(-) delete mode 100644 docs/code-quality/lint/linters/eslint-plugin-mozilla/lazy-getter-object-name.rst delete mode 100644 dom/ipc/jsactor/JSActorProtocolUtils.h delete mode 100644 dom/ipc/tests/JSProcessActor/browser_uri_combination.js delete mode 100644 dom/ipc/tests/JSWindowActor/browser_uri_combination.js delete mode 100644 js/xpconnect/tests/unit/es6module_loaded-1.sys.mjs delete mode 100644 js/xpconnect/tests/unit/es6module_loaded-2.sys.mjs delete mode 100644 js/xpconnect/tests/unit/es6module_loaded-3.sys.mjs delete mode 100644 js/xpconnect/tests/unit/esm_lazy-1.sys.mjs delete mode 100644 js/xpconnect/tests/unit/esm_lazy-2.sys.mjs delete mode 100644 js/xpconnect/tests/unit/jsm_loaded-1.jsm delete mode 100644 js/xpconnect/tests/unit/jsm_loaded-2.jsm delete mode 100644 js/xpconnect/tests/unit/jsm_loaded-3.jsm delete mode 100644 js/xpconnect/tests/unit/test_defineESModuleGetters.js delete mode 100644 js/xpconnect/tests/unit/test_loadedESModules.js delete mode 100644 toolkit/actors/TestProcessActorChild.sys.mjs delete mode 100644 toolkit/actors/TestProcessActorParent.sys.mjs delete mode 100644 toolkit/actors/TestWindowChild.sys.mjs delete mode 100644 toolkit/actors/TestWindowParent.sys.mjs rename toolkit/components/utils/{SimpleServices.sys.mjs => SimpleServices.jsm} (97%) delete mode 100644 tools/lint/eslint/eslint-plugin-mozilla/lib/rules/lazy-getter-object-name.js delete mode 100644 tools/lint/eslint/eslint-plugin-mozilla/tests/lazy-getter-object-name.js diff --git a/browser/base/content/test/static/browser_all_files_referenced.js b/browser/base/content/test/static/browser_all_files_referenced.js index 9018abc286d6..b9cb4be47500 100644 --- a/browser/base/content/test/static/browser_all_files_referenced.js +++ b/browser/base/content/test/static/browser_all_files_referenced.js @@ -832,7 +832,6 @@ add_task(async function checkAllTheFiles() { ".mjs", ".js", ".jsm", - ".mjs", ".json", ".html", ".xhtml", @@ -881,9 +880,6 @@ add_task(async function checkAllTheFiles() { for (let jsm of Components.manager.getComponentJSMs()) { gReferencesFromCode.set(jsm, null); } - for (let esModule of Components.manager.getComponentESModules()) { - gReferencesFromCode.set(esModule, null); - } // manifest.json is a common name, it is used for WebExtension manifests // but also for other things. To tell them apart, we have to actually diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla.rst index 008924f3e11a..3dfa5154acfc 100644 --- a/docs/code-quality/lint/linters/eslint-plugin-mozilla.rst +++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla.rst @@ -33,7 +33,6 @@ The plugin implements the following rules: eslint-plugin-mozilla/import-globals eslint-plugin-mozilla/import-globals-from eslint-plugin-mozilla/import-headjs-globals - eslint-plugin-mozilla/lazy-getter-object-name eslint-plugin-mozilla/mark-exported-symbols-as-used eslint-plugin-mozilla/mark-test-function-used eslint-plugin-mozilla/no-aArgs diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/lazy-getter-object-name.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/lazy-getter-object-name.rst deleted file mode 100644 index dab122def55e..000000000000 --- a/docs/code-quality/lint/linters/eslint-plugin-mozilla/lazy-getter-object-name.rst +++ /dev/null @@ -1,25 +0,0 @@ -lazy-getter-object-name -============================= - -Enforce the standard object variable name ``lazy`` for -``ChromeUtils.defineESModuleGetters`` - -Examples of incorrect code for this rule: ------------------------------------------ - -.. code-block:: js - - const obj = {}; - ChromeUtils.defineESModuleGetters(obj, { - Services: “resource://gre/modules/Services.sys.mjs”, - }); - -Examples of correct code for this rule: ---------------------------------------- - -.. code-block:: js - - const lazy = {}; - ChromeUtils.defineESModuleGetters(lazy, { - Services: “resource://gre/modules/Services.sys.mjs”, - }); diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp index f4c8678e03bd..11b04115e1ea 100644 --- a/dom/base/ChromeUtils.cpp +++ b/dom/base/ChromeUtils.cpp @@ -8,10 +8,9 @@ #include "js/CharacterEncoding.h" #include "js/Object.h" // JS::GetClass -#include "js/PropertyAndElement.h" // JS_DefineProperty, JS_DefinePropertyById, JS_Enumerate, JS_GetProperty, JS_GetPropertyById, JS_SetProperty, JS_SetPropertyById, JS::IdVector +#include "js/PropertyAndElement.h" // JS_DefineProperty, JS_DefinePropertyById, JS_Enumerate, JS_GetProperty, JS_GetPropertyById, JS_SetProperty, JS_SetPropertyById #include "js/PropertyDescriptor.h" // JS::PropertyDescriptor, JS_GetOwnPropertyDescriptorById #include "js/SavedFrameAPI.h" -#include "js/Value.h" // JS::Value, JS::StringValue #include "jsfriendapi.h" #include "WrapperFactory.h" @@ -627,10 +626,7 @@ static bool ExtractArgs(JSContext* aCx, JS::CallArgs& aArgs, return true; } -enum class ModuleType { JSM, ESM }; - -static bool ModuleGetterImpl(JSContext* aCx, unsigned aArgc, JS::Value* aVp, - ModuleType aType) { +static bool ModuleGetter(JSContext* aCx, unsigned aArgc, JS::Value* aVp) { JS::CallArgs args = JS::CallArgsFromVp(aArgc, aVp); JS::Rooted callee(aCx); @@ -651,38 +647,17 @@ static bool ModuleGetterImpl(JSContext* aCx, unsigned aArgc, JS::Value* aVp, RefPtr moduleloader = mozJSComponentLoader::Get(); MOZ_ASSERT(moduleloader); + JS::Rooted moduleGlobal(aCx); + JS::Rooted moduleExports(aCx); + nsresult rv = moduleloader->Import(aCx, uri, &moduleGlobal, &moduleExports); + if (NS_FAILED(rv)) { + Throw(aCx, rv); + return false; + } + JS::Rooted value(aCx); - if (aType == ModuleType::JSM) { - JS::Rooted moduleGlobal(aCx); - JS::Rooted moduleExports(aCx); - nsresult rv = moduleloader->Import(aCx, uri, &moduleGlobal, &moduleExports); - if (NS_FAILED(rv)) { - Throw(aCx, rv); - return false; - } - - // JSM's exports is from the same realm. - if (!JS_GetPropertyById(aCx, moduleExports, id, &value)) { - return false; - } - } else { - JS::Rooted moduleNamespace(aCx); - nsresult rv = moduleloader->ImportESModule(aCx, uri, &moduleNamespace); - if (NS_FAILED(rv)) { - Throw(aCx, rv); - return false; - } - - // ESM's namespace is from the module's realm. - { - JSAutoRealm ar(aCx, moduleNamespace); - if (!JS_GetPropertyById(aCx, moduleNamespace, id, &value)) { - return false; - } - } - if (!JS_WrapValue(aCx, &value)) { - return false; - } + if (!JS_GetPropertyById(aCx, moduleExports, id, &value)) { + return false; } if (!JS_DefinePropertyById(aCx, thisObj, id, value, JSPROP_ENUMERATE)) { @@ -693,15 +668,7 @@ static bool ModuleGetterImpl(JSContext* aCx, unsigned aArgc, JS::Value* aVp, return true; } -static bool JSModuleGetter(JSContext* aCx, unsigned aArgc, JS::Value* aVp) { - return ModuleGetterImpl(aCx, aArgc, aVp, ModuleType::JSM); -} - -static bool ESModuleGetter(JSContext* aCx, unsigned aArgc, JS::Value* aVp) { - return ModuleGetterImpl(aCx, aArgc, aVp, ModuleType::ESM); -} - -static bool ModuleSetterImpl(JSContext* aCx, unsigned aArgc, JS::Value* aVp) { +static bool ModuleSetter(JSContext* aCx, unsigned aArgc, JS::Value* aVp) { JS::CallArgs args = JS::CallArgsFromVp(aArgc, aVp); JS::Rooted callee(aCx); @@ -714,17 +681,8 @@ static bool ModuleSetterImpl(JSContext* aCx, unsigned aArgc, JS::Value* aVp) { return JS_DefinePropertyById(aCx, thisObj, id, args.get(0), JSPROP_ENUMERATE); } -static bool JSModuleSetter(JSContext* aCx, unsigned aArgc, JS::Value* aVp) { - return ModuleSetterImpl(aCx, aArgc, aVp); -} - -static bool ESModuleSetter(JSContext* aCx, unsigned aArgc, JS::Value* aVp) { - return ModuleSetterImpl(aCx, aArgc, aVp); -} - -static bool DefineJSModuleGetter(JSContext* aCx, JS::Handle aTarget, - const nsAString& aId, - const nsAString& aResourceURI) { +static bool DefineGetter(JSContext* aCx, JS::Handle aTarget, + const nsAString& aId, const nsAString& aResourceURI) { JS::Rooted uri(aCx); JS::Rooted idValue(aCx); JS::Rooted id(aCx); @@ -737,11 +695,11 @@ static bool DefineJSModuleGetter(JSContext* aCx, JS::Handle aTarget, JS::Rooted getter( aCx, JS_GetFunctionObject( - js::NewFunctionByIdWithReserved(aCx, JSModuleGetter, 0, 0, id))); + js::NewFunctionByIdWithReserved(aCx, ModuleGetter, 0, 0, id))); JS::Rooted setter( aCx, JS_GetFunctionObject( - js::NewFunctionByIdWithReserved(aCx, JSModuleSetter, 0, 0, id))); + js::NewFunctionByIdWithReserved(aCx, ModuleSetter, 0, 0, id))); if (!getter || !setter) { JS_ReportOutOfMemory(aCx); @@ -756,33 +714,6 @@ static bool DefineJSModuleGetter(JSContext* aCx, JS::Handle aTarget, return JS_DefinePropertyById(aCx, aTarget, id, getter, setter, JSPROP_ENUMERATE); } - -static bool DefineESModuleGetter(JSContext* aCx, JS::Handle aTarget, - JS::Handle aId, - JS::Handle aResourceURI) { - JS::Rooted idVal(aCx, JS::StringValue(aId.toString())); - - JS::Rooted getter( - aCx, JS_GetFunctionObject(js::NewFunctionByIdWithReserved( - aCx, ESModuleGetter, 0, 0, aId))); - - JS::Rooted setter( - aCx, JS_GetFunctionObject(js::NewFunctionByIdWithReserved( - aCx, ESModuleSetter, 0, 0, aId))); - - if (!getter || !setter) { - JS_ReportOutOfMemory(aCx); - return false; - } - - js::SetFunctionNativeReserved(getter, SLOT_ID, idVal); - js::SetFunctionNativeReserved(setter, SLOT_ID, idVal); - - js::SetFunctionNativeReserved(getter, SLOT_URI, aResourceURI); - - return JS_DefinePropertyById(aCx, aTarget, aId, getter, setter, - JSPROP_ENUMERATE); -} } // namespace module_getter /* static */ @@ -791,48 +722,11 @@ void ChromeUtils::DefineModuleGetter(const GlobalObject& global, const nsAString& id, const nsAString& resourceURI, ErrorResult& aRv) { - if (!module_getter::DefineJSModuleGetter(global.Context(), target, id, - resourceURI)) { + if (!module_getter::DefineGetter(global.Context(), target, id, resourceURI)) { aRv.NoteJSContextException(global.Context()); } } -/* static */ -void ChromeUtils::DefineESModuleGetters(const GlobalObject& global, - JS::Handle target, - JS::Handle modules, - ErrorResult& aRv) { - auto cx = global.Context(); - - JS::Rooted props(cx, JS::IdVector(cx)); - if (!JS_Enumerate(cx, modules, &props)) { - aRv.NoteJSContextException(cx); - return; - } - - JS::Rooted prop(cx); - JS::Rooted resourceURIVal(cx); - for (JS::PropertyKey tmp : props) { - prop = tmp; - - if (!prop.isString()) { - aRv.Throw(NS_ERROR_FAILURE); - return; - } - - if (!JS_GetPropertyById(cx, modules, prop, &resourceURIVal)) { - aRv.NoteJSContextException(cx); - return; - } - - if (!module_getter::DefineESModuleGetter(cx, target, prop, - resourceURIVal)) { - aRv.NoteJSContextException(cx); - return; - } - } -} - /* static */ void ChromeUtils::OriginAttributesToSuffix( dom::GlobalObject& aGlobal, const dom::OriginAttributesDictionary& aAttrs, diff --git a/dom/base/ChromeUtils.h b/dom/base/ChromeUtils.h index be7d764c4fe5..36b87244945c 100644 --- a/dom/base/ChromeUtils.h +++ b/dom/base/ChromeUtils.h @@ -211,11 +211,6 @@ class ChromeUtils { const nsAString& resourceURI, ErrorResult& aRv); - static void DefineESModuleGetters(const GlobalObject& global, - JS::Handle target, - JS::Handle modules, - ErrorResult& aRv); - static void GetCallerLocation(const GlobalObject& global, nsIPrincipal* principal, JS::MutableHandle aRetval); diff --git a/dom/chrome-webidl/ChromeUtils.webidl b/dom/chrome-webidl/ChromeUtils.webidl index 05c19dcfc9c0..f0b77c1985d6 100644 --- a/dom/chrome-webidl/ChromeUtils.webidl +++ b/dom/chrome-webidl/ChromeUtils.webidl @@ -475,18 +475,6 @@ partial namespace ChromeUtils { [Throws] void defineModuleGetter(object target, DOMString id, DOMString resourceURI); - /** - * Defines propertys on the given target which lazily imports a ES module - * when accessed. - * - * @param target The target object on which to define the property. - * @param modules An object with a property for each module property to be - * imported, where the property name is the name of the - * imported symbol and the value is the module URI. - */ - [Throws] - void defineESModuleGetters(object target, object modules); - /** * Returns the scripted location of the first ancestor stack frame with a * principal which is subsumed by the given principal. If no such frame diff --git a/dom/chrome-webidl/JSProcessActor.webidl b/dom/chrome-webidl/JSProcessActor.webidl index 13a706242741..09536fe7b599 100644 --- a/dom/chrome-webidl/JSProcessActor.webidl +++ b/dom/chrome-webidl/JSProcessActor.webidl @@ -62,24 +62,10 @@ dictionary ProcessActorOptions { dictionary ProcessActorSidedOptions { /** * The JSM path which should be loaded for the actor on this side. - * - * Mutually exclusive with `esModuleURI`. - * - * If neither this nor `esModuleURI` is passed, the specified side cannot receive - * messages, but may send them using `sendAsyncMessage` or `sendQuery`. + * If not passed, the specified side cannot receive messages, but may send + * them using `sendAsyncMessage` or `sendQuery`. */ - ByteString moduleURI; - - /** - * The ESM path which should be loaded for the actor on this side. - * - * Mutually exclusive with `moduleURI`. - * - * If neither this nor `moduleURI` is passed, the specified side cannot - * receive messages, but may send them using `sendAsyncMessage` or - * `sendQuery`. - */ - ByteString esModuleURI; + required ByteString moduleURI; }; dictionary ProcessActorChildOptions : ProcessActorSidedOptions { diff --git a/dom/chrome-webidl/JSWindowActor.webidl b/dom/chrome-webidl/JSWindowActor.webidl index 767b4854c50f..60ad1662cafe 100644 --- a/dom/chrome-webidl/JSWindowActor.webidl +++ b/dom/chrome-webidl/JSWindowActor.webidl @@ -127,24 +127,10 @@ dictionary WindowActorOptions { dictionary WindowActorSidedOptions { /** * The JSM path which should be loaded for the actor on this side. - * - * Mutually exclusive with `esModuleURI`. - * - * If neither this nor `esModuleURI` is passed, the specified side cannot receive - * messages, but may send them using `sendAsyncMessage` or `sendQuery`. + * If not passed, the specified side cannot receive messages, but may send + * them using `sendAsyncMessage` or `sendQuery`. */ - ByteString moduleURI; - - /** - * The ESM path which should be loaded for the actor on this side. - * - * Mutually exclusive with `moduleURI`. - * - * If neither this nor `moduleURI` is passed, the specified side cannot - * receive messages, but may send them using `sendAsyncMessage` or - * `sendQuery`. - */ - ByteString esModuleURI; + required ByteString moduleURI; }; dictionary WindowActorEventListenerOptions : AddEventListenerOptions { diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 35f03a2df964..75914f210f0a 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -294,10 +294,6 @@ struct JSWindowActorInfo nsCString name; bool allFrames; - // True if `url` is for ESM. - // False if `url` is for JSM or nothing. - bool isESModule; - // The module of the url. nsCString? url; @@ -314,11 +310,6 @@ struct JSProcessActorInfo { // The name of the actor. nsCString name; - - // True if `url` is for ESM. - // False if `url` is for JSM or nothing. - bool isESModule; - // The module of the url. nsCString? url; diff --git a/dom/ipc/jsactor/JSActorManager.cpp b/dom/ipc/jsactor/JSActorManager.cpp index cdc5f240ef7b..69cdbdb9f17d 100644 --- a/dom/ipc/jsactor/JSActorManager.cpp +++ b/dom/ipc/jsactor/JSActorManager.cpp @@ -65,25 +65,18 @@ already_AddRefed JSActorManager::GetActor(JSContext* aCx, MOZ_ASSERT(loader); // If a module URI was provided, use it to construct an instance of the actor. - JS::Rooted actorObj(aCx); - if (side.mModuleURI || side.mESModuleURI) { - JS::Rooted exports(aCx); - if (side.mModuleURI) { - JS::Rooted global(aCx); - aRv = loader->Import(aCx, side.mModuleURI.ref(), &global, &exports); - if (aRv.Failed()) { - return nullptr; - } - } else { - aRv = loader->ImportESModule(aCx, side.mESModuleURI.ref(), &exports); - if (aRv.Failed()) { - return nullptr; - } + JS::RootedObject actorObj(aCx); + if (side.mModuleURI) { + JS::RootedObject global(aCx); + JS::RootedObject exports(aCx); + aRv = loader->Import(aCx, side.mModuleURI.ref(), &global, &exports); + if (aRv.Failed()) { + return nullptr; } MOZ_ASSERT(exports, "null exports!"); // Load the specific property from our module. - JS::Rooted ctor(aCx); + JS::RootedValue ctor(aCx); nsAutoCString ctorName(aName); ctorName.Append(isParent ? "Parent"_ns : "Child"_ns); if (!JS_GetProperty(aCx, exports, ctorName.get(), &ctor)) { diff --git a/dom/ipc/jsactor/JSActorProtocolUtils.h b/dom/ipc/jsactor/JSActorProtocolUtils.h deleted file mode 100644 index b1fb4d461ca1..000000000000 --- a/dom/ipc/jsactor/JSActorProtocolUtils.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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/. */ - -#ifndef mozilla_dom_JSActorProtocolUtils_h -#define mozilla_dom_JSActorProtocolUtils_h - -#include "mozilla/Assertions.h" // MOZ_ASSERT -#include "mozilla/ErrorResult.h" // ErrorResult - -namespace mozilla { - -namespace dom { - -class JSActorProtocolUtils { - public: - template - static void FromIPCShared(ProtoT& aProto, const ActorInfoT& aInfo) { - aProto->mRemoteTypes = aInfo.remoteTypes().Clone(); - - if (aInfo.isESModule()) { - aProto->mChild.mESModuleURI = aInfo.url(); - } else { - aProto->mChild.mModuleURI = aInfo.url(); - } - - aProto->mChild.mObservers = aInfo.observers().Clone(); - } - - template - static void ToIPCShared(ActorInfoT& aInfo, const ProtoT& aProto) { - aInfo.name() = aProto->mName; - - aInfo.remoteTypes() = aProto->mRemoteTypes.Clone(); - - if (aProto->mChild.mModuleURI) { - aInfo.url() = aProto->mChild.mModuleURI; - aInfo.isESModule() = false; - } else { - aInfo.url() = aProto->mChild.mESModuleURI; - aInfo.isESModule() = true; - } - - aInfo.observers() = aProto->mChild.mObservers.Clone(); - } - - template - static bool FromWebIDLOptionsShared(ProtoT& aProto, - const ActorOptionsT& aOptions, - ErrorResult& aRv) { - if (aOptions.mRemoteTypes.WasPassed()) { - MOZ_ASSERT(aOptions.mRemoteTypes.Value().Length()); - aProto->mRemoteTypes = aOptions.mRemoteTypes.Value(); - } - - if (aOptions.mParent.WasPassed()) { - const auto& parentOptions = aOptions.mParent.Value(); - - if (parentOptions.mModuleURI.WasPassed()) { - if (parentOptions.mEsModuleURI.WasPassed()) { - aRv.ThrowNotSupportedError( - "moduleURI and esModuleURI are mutually exclusive."); - return false; - } - - aProto->mParent.mModuleURI.emplace(parentOptions.mModuleURI.Value()); - } else if (parentOptions.mEsModuleURI.WasPassed()) { - aProto->mParent.mESModuleURI.emplace( - parentOptions.mEsModuleURI.Value()); - } else { - aRv.ThrowNotSupportedError( - "Either moduleURI or esModuleURI is required."); - return false; - } - } - if (aOptions.mChild.WasPassed()) { - const auto& childOptions = aOptions.mChild.Value(); - - if (childOptions.mModuleURI.WasPassed()) { - if (childOptions.mEsModuleURI.WasPassed()) { - aRv.ThrowNotSupportedError( - "moduleURI and esModuleURI are exclusive."); - return false; - } - - aProto->mChild.mModuleURI.emplace(childOptions.mModuleURI.Value()); - } else if (childOptions.mEsModuleURI.WasPassed()) { - aProto->mChild.mESModuleURI.emplace(childOptions.mEsModuleURI.Value()); - } else { - aRv.ThrowNotSupportedError( - "Either moduleURI or esModuleURI is required."); - return false; - } - } - - if (!aOptions.mChild.WasPassed() && !aOptions.mParent.WasPassed()) { - aRv.ThrowNotSupportedError( - "No point registering an actor with neither child nor parent " - "specifications."); - return false; - } - - if (aOptions.mChild.WasPassed() && - aOptions.mChild.Value().mObservers.WasPassed()) { - aProto->mChild.mObservers = aOptions.mChild.Value().mObservers.Value(); - } - - return true; - } -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_JSActorProtocolUtils_h diff --git a/dom/ipc/jsactor/JSActorService.h b/dom/ipc/jsactor/JSActorService.h index e3296e193447..610d0fc99604 100644 --- a/dom/ipc/jsactor/JSActorService.h +++ b/dom/ipc/jsactor/JSActorService.h @@ -99,7 +99,6 @@ class JSActorProtocol : public nsISupports { public: struct Sided { Maybe mModuleURI; - Maybe mESModuleURI; }; virtual const Sided& Parent() const = 0; diff --git a/dom/ipc/jsactor/JSProcessActorProtocol.cpp b/dom/ipc/jsactor/JSProcessActorProtocol.cpp index 367db5305b22..58d0051210e1 100644 --- a/dom/ipc/jsactor/JSProcessActorProtocol.cpp +++ b/dom/ipc/jsactor/JSProcessActorProtocol.cpp @@ -12,9 +12,7 @@ #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/JSActorBinding.h" #include "mozilla/dom/PContent.h" - #include "nsContentUtils.h" -#include "JSActorProtocolUtils.h" namespace mozilla::dom { @@ -33,11 +31,13 @@ JSProcessActorProtocol::FromIPC(const JSProcessActorInfo& aInfo) { RefPtr proto = new JSProcessActorProtocol(aInfo.name()); - JSActorProtocolUtils::FromIPCShared(proto, aInfo); // Content processes aren't the parent process, so this flag is irrelevant and // not propagated. proto->mIncludeParent = false; + proto->mRemoteTypes = aInfo.remoteTypes().Clone(); + proto->mChild.mModuleURI = aInfo.url(); + proto->mChild.mObservers = aInfo.observers().Clone(); return proto.forget(); } @@ -46,8 +46,10 @@ JSProcessActorInfo JSProcessActorProtocol::ToIPC() { MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess()); JSProcessActorInfo info; - JSActorProtocolUtils::ToIPCShared(info, this); - + info.name() = mName; + info.remoteTypes() = mRemoteTypes.Clone(); + info.url() = mChild.mModuleURI; + info.observers() = mChild.mObservers.Clone(); return info; } @@ -58,11 +60,31 @@ JSProcessActorProtocol::FromWebIDLOptions(const nsACString& aName, MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess()); RefPtr proto = new JSProcessActorProtocol(aName); - if (!JSActorProtocolUtils::FromWebIDLOptionsShared(proto, aOptions, aRv)) { + proto->mIncludeParent = aOptions.mIncludeParent; + + if (aOptions.mRemoteTypes.WasPassed()) { + MOZ_ASSERT(aOptions.mRemoteTypes.Value().Length()); + proto->mRemoteTypes = aOptions.mRemoteTypes.Value(); + } + + if (aOptions.mParent.WasPassed()) { + proto->mParent.mModuleURI.emplace(aOptions.mParent.Value().mModuleURI); + } + if (aOptions.mChild.WasPassed()) { + proto->mChild.mModuleURI.emplace(aOptions.mChild.Value().mModuleURI); + } + + if (!aOptions.mChild.WasPassed() && !aOptions.mParent.WasPassed()) { + aRv.ThrowNotSupportedError( + "No point registering an actor with neither child nor parent " + "specifications."); return nullptr; } - proto->mIncludeParent = aOptions.mIncludeParent; + if (aOptions.mChild.WasPassed() && + aOptions.mChild.Value().mObservers.WasPassed()) { + proto->mChild.mObservers = aOptions.mChild.Value().mObservers.Value(); + } return proto.forget(); } diff --git a/dom/ipc/jsactor/JSProcessActorProtocol.h b/dom/ipc/jsactor/JSProcessActorProtocol.h index eab8876c351f..2230283dcf61 100644 --- a/dom/ipc/jsactor/JSProcessActorProtocol.h +++ b/dom/ipc/jsactor/JSProcessActorProtocol.h @@ -22,7 +22,6 @@ namespace dom { struct ProcessActorOptions; class JSProcessActorInfo; class EventTarget; -class JSActorProtocolUtils; /** * Object corresponding to a single process actor protocol @@ -67,8 +66,6 @@ class JSProcessActorProtocol final : public JSActorProtocol, nsTArray mRemoteTypes; bool mIncludeParent = false; - friend class JSActorProtocolUtils; - ParentSide mParent; ChildSide mChild; }; diff --git a/dom/ipc/jsactor/JSWindowActorProtocol.cpp b/dom/ipc/jsactor/JSWindowActorProtocol.cpp index ec2f10529401..131f2f4aaec7 100644 --- a/dom/ipc/jsactor/JSWindowActorProtocol.cpp +++ b/dom/ipc/jsactor/JSWindowActorProtocol.cpp @@ -16,7 +16,6 @@ #include "mozilla/dom/WindowGlobalChild.h" #include "nsContentUtils.h" -#include "JSActorProtocolUtils.h" namespace mozilla::dom { @@ -35,14 +34,14 @@ JSWindowActorProtocol::FromIPC(const JSWindowActorInfo& aInfo) { MOZ_DIAGNOSTIC_ASSERT(XRE_IsContentProcess()); RefPtr proto = new JSWindowActorProtocol(aInfo.name()); - JSActorProtocolUtils::FromIPCShared(proto, aInfo); - // Content processes cannot load chrome browsing contexts, so this flag is // irrelevant and not propagated. proto->mIncludeChrome = false; proto->mAllFrames = aInfo.allFrames(); proto->mMatches = aInfo.matches().Clone(); + proto->mRemoteTypes = aInfo.remoteTypes().Clone(); proto->mMessageManagerGroups = aInfo.messageManagerGroups().Clone(); + proto->mChild.mModuleURI = aInfo.url(); proto->mChild.mEvents.SetCapacity(aInfo.events().Length()); for (auto& ipc : aInfo.events()) { @@ -57,6 +56,7 @@ JSWindowActorProtocol::FromIPC(const JSWindowActorInfo& aInfo) { event->mCreateActor = ipc.createActor(); } + proto->mChild.mObservers = aInfo.observers().Clone(); return proto.forget(); } @@ -64,11 +64,12 @@ JSWindowActorInfo JSWindowActorProtocol::ToIPC() { MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess()); JSWindowActorInfo info; - JSActorProtocolUtils::ToIPCShared(info, this); - + info.name() = mName; info.allFrames() = mAllFrames; info.matches() = mMatches.Clone(); + info.remoteTypes() = mRemoteTypes.Clone(); info.messageManagerGroups() = mMessageManagerGroups.Clone(); + info.url() = mChild.mModuleURI; info.events().SetCapacity(mChild.mEvents.Length()); for (auto& event : mChild.mEvents) { @@ -83,6 +84,7 @@ JSWindowActorInfo JSWindowActorProtocol::ToIPC() { ipc->createActor() = event.mCreateActor; } + info.observers() = mChild.mObservers.Clone(); return info; } @@ -93,10 +95,6 @@ JSWindowActorProtocol::FromWebIDLOptions(const nsACString& aName, MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess()); RefPtr proto = new JSWindowActorProtocol(aName); - if (!JSActorProtocolUtils::FromWebIDLOptionsShared(proto, aOptions, aRv)) { - return nullptr; - } - proto->mAllFrames = aOptions.mAllFrames; proto->mIncludeChrome = aOptions.mIncludeChrome; @@ -105,10 +103,29 @@ JSWindowActorProtocol::FromWebIDLOptions(const nsACString& aName, proto->mMatches = aOptions.mMatches.Value(); } + if (aOptions.mRemoteTypes.WasPassed()) { + MOZ_ASSERT(aOptions.mRemoteTypes.Value().Length()); + proto->mRemoteTypes = aOptions.mRemoteTypes.Value(); + } + if (aOptions.mMessageManagerGroups.WasPassed()) { proto->mMessageManagerGroups = aOptions.mMessageManagerGroups.Value(); } + if (aOptions.mParent.WasPassed()) { + proto->mParent.mModuleURI.emplace(aOptions.mParent.Value().mModuleURI); + } + if (aOptions.mChild.WasPassed()) { + proto->mChild.mModuleURI.emplace(aOptions.mChild.Value().mModuleURI); + } + + if (!aOptions.mChild.WasPassed() && !aOptions.mParent.WasPassed()) { + aRv.ThrowNotSupportedError( + "No point registering an actor with neither child nor parent " + "specifications."); + return nullptr; + } + // For each event declared in the source dictionary, initialize the // corresponding event declaration entry in the JSWindowActorProtocol. if (aOptions.mChild.WasPassed() && @@ -140,6 +157,11 @@ JSWindowActorProtocol::FromWebIDLOptions(const nsACString& aName, } } + if (aOptions.mChild.WasPassed() && + aOptions.mChild.Value().mObservers.WasPassed()) { + proto->mChild.mObservers = aOptions.mChild.Value().mObservers.Value(); + } + return proto.forget(); } diff --git a/dom/ipc/jsactor/JSWindowActorProtocol.h b/dom/ipc/jsactor/JSWindowActorProtocol.h index 35eb1a70185b..e39babdc3434 100644 --- a/dom/ipc/jsactor/JSWindowActorProtocol.h +++ b/dom/ipc/jsactor/JSWindowActorProtocol.h @@ -24,7 +24,6 @@ namespace dom { struct WindowActorOptions; class JSWindowActorInfo; class EventTarget; -class JSActorProtocolUtils; /** * Object corresponding to a single window actor protocol. This object acts as @@ -89,8 +88,6 @@ class JSWindowActorProtocol final : public JSActorProtocol, nsTArray mRemoteTypes; nsTArray mMessageManagerGroups; - friend class JSActorProtocolUtils; - ParentSide mParent; ChildSide mChild; diff --git a/dom/ipc/tests/JSProcessActor/browser.ini b/dom/ipc/tests/JSProcessActor/browser.ini index 021b8d84d95e..c3d8645a3329 100644 --- a/dom/ipc/tests/JSProcessActor/browser.ini +++ b/dom/ipc/tests/JSProcessActor/browser.ini @@ -8,4 +8,4 @@ support-files = [browser_registerProcessActor.js] [browser_sendAsyncMessage.js] [browser_sendQuery.js] -[browser_uri_combination.js] \ No newline at end of file + diff --git a/dom/ipc/tests/JSProcessActor/browser_registerProcessActor.js b/dom/ipc/tests/JSProcessActor/browser_registerProcessActor.js index 1fa4e1c17c79..e57f7627440d 100644 --- a/dom/ipc/tests/JSProcessActor/browser_registerProcessActor.js +++ b/dom/ipc/tests/JSProcessActor/browser_registerProcessActor.js @@ -3,12 +3,12 @@ "use strict"; declTest("double register", { - async test(_browser, _window, fileExt) { + async test() { SimpleTest.doesThrow( () => ChromeUtils.registerContentActor( "TestProcessActor", - processActorOptions[fileExt] + processActorOptions ), "Should throw if register has duplicate name." ); diff --git a/dom/ipc/tests/JSProcessActor/browser_sendQuery.js b/dom/ipc/tests/JSProcessActor/browser_sendQuery.js index b19e66ee9190..69fe881367c4 100644 --- a/dom/ipc/tests/JSProcessActor/browser_sendQuery.js +++ b/dom/ipc/tests/JSProcessActor/browser_sendQuery.js @@ -2,23 +2,6 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; -const ERROR_LINE_NUMBERS = { - jsm: 33, - "sys.mjs": 31, -}; -const EXCEPTION_LINE_NUMBERS = { - jsm: ERROR_LINE_NUMBERS.jsm + 3, - "sys.mjs": ERROR_LINE_NUMBERS["sys.mjs"] + 3, -}; -const ERROR_COLUMN_NUMBERS = { - jsm: 31, - "sys.mjs": 31, -}; -const EXCEPTION_COLUMN_NUMBERS = { - jsm: 22, - "sys.mjs": 22, -}; - function maybeAsyncStack(offset, column) { if ( Services.prefs.getBoolPref( @@ -39,7 +22,7 @@ function maybeAsyncStack(offset, column) { } declTest("sendQuery Error", { - async test(browser, _window, fileExt) { + async test(browser) { let parent = browser.browsingContext.currentWindowGlobal.domProcess; let actorParent = parent.getActor("TestProcessActor"); @@ -52,7 +35,7 @@ declTest("sendQuery Error", { is(error.name, "SyntaxError", "Error should have the correct name"); is( error.stack, - `receiveMessage@resource://testing-common/TestProcessActorChild.${fileExt}:${ERROR_LINE_NUMBERS[fileExt]}:${ERROR_COLUMN_NUMBERS[fileExt]}\n` + + "receiveMessage@resource://testing-common/TestProcessActorChild.jsm:33:31\n" + asyncStack, "Error should have the correct stack" ); @@ -60,7 +43,7 @@ declTest("sendQuery Error", { }); declTest("sendQuery Exception", { - async test(browser, _window, fileExt) { + async test(browser) { let parent = browser.browsingContext.currentWindowGlobal.domProcess; let actorParent = parent.getActor("TestProcessActor"); @@ -80,7 +63,7 @@ declTest("sendQuery Exception", { ); is( error.stack, - `receiveMessage@resource://testing-common/TestProcessActorChild.${fileExt}:${EXCEPTION_LINE_NUMBERS[fileExt]}:${EXCEPTION_COLUMN_NUMBERS[fileExt]}\n` + + "receiveMessage@resource://testing-common/TestProcessActorChild.jsm:36:22\n" + asyncStack, "Error should have the correct stack" ); diff --git a/dom/ipc/tests/JSProcessActor/browser_uri_combination.js b/dom/ipc/tests/JSProcessActor/browser_uri_combination.js deleted file mode 100644 index 33394cf54a7b..000000000000 --- a/dom/ipc/tests/JSProcessActor/browser_uri_combination.js +++ /dev/null @@ -1,81 +0,0 @@ -add_task(function specify_both() { - // Specifying both should throw. - - SimpleTest.doesThrow(() => { - ChromeUtils.registerProcessActor("TestProcessActor", { - parent: { - moduleURI: "resource://testing-common/TestProcessActorParent.jsm", - }, - child: { - moduleURI: "resource://testing-common/TestProcessActorChild.jsm", - esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs", - }, - }); - }, "Should throw if both moduleURI and esModuleURI are specified."); - - SimpleTest.doesThrow(() => { - ChromeUtils.registerProcessActor("TestProcessActor", { - parent: { - esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs", - }, - child: { - moduleURI: "resource://testing-common/TestProcessActorChild.jsm", - esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs", - }, - }); - }, "Should throw if both moduleURI and esModuleURI are specified."); - - SimpleTest.doesThrow(() => { - ChromeUtils.registerProcessActor("TestProcessActor", { - parent: { - moduleURI: "resource://testing-common/TestProcessActorParent.jsm", - esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs", - }, - child: { - moduleURI: "resource://testing-common/TestProcessActorChild.jsm", - }, - }); - }, "Should throw if both moduleURI and esModuleURI are specified."); - - SimpleTest.doesThrow(() => { - ChromeUtils.registerProcessActor("TestProcessActor", { - parent: { - moduleURI: "resource://testing-common/TestProcessActorParent.jsm", - esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs", - }, - child: { - esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs", - }, - }); - }, "Should throw if both moduleURI and esModuleURI are specified."); -}); - -add_task(function specify_mixed() { - // Mixing JSM and ESM should work. - - try { - ChromeUtils.registerProcessActor("TestProcessActor", { - parent: { - moduleURI: "resource://testing-common/TestProcessActorParent.jsm", - }, - child: { - esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs", - }, - }); - } finally { - ChromeUtils.unregisterProcessActor("TestProcessActor"); - } - - try { - ChromeUtils.registerProcessActor("TestProcessActor", { - parent: { - esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs", - }, - child: { - moduleURI: "resource://testing-common/TestProcessActorChild.jsm", - }, - }); - } finally { - ChromeUtils.unregisterProcessActor("TestProcessActor"); - } -}); diff --git a/dom/ipc/tests/JSProcessActor/head.js b/dom/ipc/tests/JSProcessActor/head.js index bbcfcfbe5c31..86f35f4c5725 100644 --- a/dom/ipc/tests/JSProcessActor/head.js +++ b/dom/ipc/tests/JSProcessActor/head.js @@ -8,23 +8,12 @@ const URL = "about:blank"; const TEST_URL = "http://test2.example.org/"; let processActorOptions = { - jsm: { - parent: { - moduleURI: "resource://testing-common/TestProcessActorParent.jsm", - }, - child: { - moduleURI: "resource://testing-common/TestProcessActorChild.jsm", - observers: ["test-js-content-actor-child-observer"], - }, + parent: { + moduleURI: "resource://testing-common/TestProcessActorParent.jsm", }, - "sys.mjs": { - parent: { - esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs", - }, - child: { - esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs", - observers: ["test-js-content-actor-child-observer"], - }, + child: { + moduleURI: "resource://testing-common/TestProcessActorChild.jsm", + observers: ["test-js-content-actor-child-observer"], }, }; @@ -44,18 +33,13 @@ function promiseNotification(aNotification) { } function declTest(name, cfg) { - declTestWithOptions(name, cfg, "jsm"); - declTestWithOptions(name, cfg, "sys.mjs"); -} - -function declTestWithOptions(name, cfg, fileExt) { let { url = "about:blank", includeParent = false, remoteTypes, test } = cfg; // Build the actor options object which will be used to register & unregister // our process actor. let actorOptions = { - parent: Object.assign({}, processActorOptions[fileExt].parent), - child: Object.assign({}, processActorOptions[fileExt].child), + parent: Object.assign({}, processActorOptions.parent), + child: Object.assign({}, processActorOptions.child), }; actorOptions.includeParent = includeParent; if (remoteTypes !== undefined) { @@ -71,7 +55,7 @@ function declTestWithOptions(name, cfg, fileExt) { try { await BrowserTestUtils.withNewTab(url, async browser => { info("browser ready"); - await Promise.resolve(test(browser, window, fileExt)); + await Promise.resolve(test(browser, window)); }); } finally { // Unregister the actor after the test is complete. diff --git a/dom/ipc/tests/JSWindowActor/browser.ini b/dom/ipc/tests/JSWindowActor/browser.ini index d7c8ad71abcf..85da58675866 100644 --- a/dom/ipc/tests/JSWindowActor/browser.ini +++ b/dom/ipc/tests/JSWindowActor/browser.ini @@ -19,4 +19,3 @@ support-files= [browser_registerWindowActor.js] [browser_sendAsyncMessage.js] [browser_sendQuery.js] -[browser_uri_combination.js] diff --git a/dom/ipc/tests/JSWindowActor/browser_registerWindowActor.js b/dom/ipc/tests/JSWindowActor/browser_registerWindowActor.js index edaa99d2edee..838fa653b42d 100644 --- a/dom/ipc/tests/JSWindowActor/browser_registerWindowActor.js +++ b/dom/ipc/tests/JSWindowActor/browser_registerWindowActor.js @@ -3,13 +3,9 @@ "use strict"; declTest("double register", { - async test(_browser, _window, fileExt) { + async test() { SimpleTest.doesThrow( - () => - ChromeUtils.registerWindowActor( - "TestWindow", - windowActorOptions[fileExt] - ), + () => ChromeUtils.registerWindowActor("TestWindow", windowActorOptions), "Should throw if register has duplicate name." ); }, diff --git a/dom/ipc/tests/JSWindowActor/browser_sendQuery.js b/dom/ipc/tests/JSWindowActor/browser_sendQuery.js index 6409546a1141..149744a2fc18 100644 --- a/dom/ipc/tests/JSWindowActor/browser_sendQuery.js +++ b/dom/ipc/tests/JSWindowActor/browser_sendQuery.js @@ -2,22 +2,8 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; -const ERROR_LINE_NUMBERS = { - jsm: 41, - "sys.mjs": 39, -}; -const EXCEPTION_LINE_NUMBERS = { - jsm: ERROR_LINE_NUMBERS.jsm + 3, - "sys.mjs": ERROR_LINE_NUMBERS["sys.mjs"] + 3, -}; -const ERROR_COLUMN_NUMBERS = { - jsm: 31, - "sys.mjs": 31, -}; -const EXCEPTION_COLUMN_NUMBERS = { - jsm: 22, - "sys.mjs": 22, -}; +const ERROR_LINE_NUMBER = 41; +const EXCEPTION_LINE_NUMBER = ERROR_LINE_NUMBER + 3; function maybeAsyncStack(offset, column) { if ( @@ -39,7 +25,7 @@ function maybeAsyncStack(offset, column) { } declTest("sendQuery Error", { - async test(browser, _window, fileExt) { + async test(browser) { let parent = browser.browsingContext.currentWindowGlobal; let actorParent = parent.getActor("TestWindow"); @@ -52,7 +38,7 @@ declTest("sendQuery Error", { is(error.name, "SyntaxError", "Error should have the correct name"); is( error.stack, - `receiveMessage@resource://testing-common/TestWindowChild.${fileExt}:${ERROR_LINE_NUMBERS[fileExt]}:${ERROR_COLUMN_NUMBERS[fileExt]}\n` + + `receiveMessage@resource://testing-common/TestWindowChild.jsm:${ERROR_LINE_NUMBER}:31\n` + asyncStack, "Error should have the correct stack" ); @@ -60,7 +46,7 @@ declTest("sendQuery Error", { }); declTest("sendQuery Exception", { - async test(browser, _window, fileExt) { + async test(browser) { let parent = browser.browsingContext.currentWindowGlobal; let actorParent = parent.getActor("TestWindow"); @@ -80,7 +66,7 @@ declTest("sendQuery Exception", { ); is( error.stack, - `receiveMessage@resource://testing-common/TestWindowChild.${fileExt}:${EXCEPTION_LINE_NUMBERS[fileExt]}:${EXCEPTION_COLUMN_NUMBERS[fileExt]}\n` + + `receiveMessage@resource://testing-common/TestWindowChild.jsm:${EXCEPTION_LINE_NUMBER}:22\n` + asyncStack, "Error should have the correct stack" ); diff --git a/dom/ipc/tests/JSWindowActor/browser_uri_combination.js b/dom/ipc/tests/JSWindowActor/browser_uri_combination.js deleted file mode 100644 index ce46a3e3b61a..000000000000 --- a/dom/ipc/tests/JSWindowActor/browser_uri_combination.js +++ /dev/null @@ -1,81 +0,0 @@ -add_task(function specify_both() { - // Specifying both should throw. - - SimpleTest.doesThrow(() => { - ChromeUtils.registerWindowActor("TestWindow", { - parent: { - moduleURI: "resource://testing-common/TestWindowParent.jsm", - }, - child: { - moduleURI: "resource://testing-common/TestWindowChild.jsm", - esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs", - }, - }); - }, "Should throw if both moduleURI and esModuleURI are specified."); - - SimpleTest.doesThrow(() => { - ChromeUtils.registerWindowActor("TestWindow", { - parent: { - esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs", - }, - child: { - moduleURI: "resource://testing-common/TestWindowChild.jsm", - esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs", - }, - }); - }, "Should throw if both moduleURI and esModuleURI are specified."); - - SimpleTest.doesThrow(() => { - ChromeUtils.registerWindowActor("TestWindow", { - parent: { - moduleURI: "resource://testing-common/TestWindowParent.jsm", - esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs", - }, - child: { - moduleURI: "resource://testing-common/TestWindowChild.jsm", - }, - }); - }, "Should throw if both moduleURI and esModuleURI are specified."); - - SimpleTest.doesThrow(() => { - ChromeUtils.registerWindowActor("TestWindow", { - parent: { - moduleURI: "resource://testing-common/TestWindowParent.jsm", - esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs", - }, - child: { - esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs", - }, - }); - }, "Should throw if both moduleURI and esModuleURI are specified."); -}); - -add_task(function specify_mixed() { - // Mixing JSM and ESM should work. - - try { - ChromeUtils.registerWindowActor("TestWindow", { - parent: { - moduleURI: "resource://testing-common/TestWindowParent.jsm", - }, - child: { - esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs", - }, - }); - } finally { - ChromeUtils.unregisterWindowActor("TestWindow"); - } - - try { - ChromeUtils.registerWindowActor("TestWindow", { - parent: { - esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs", - }, - child: { - moduleURI: "resource://testing-common/TestWindowChild.jsm", - }, - }); - } finally { - ChromeUtils.unregisterWindowActor("TestWindow"); - } -}); diff --git a/dom/ipc/tests/JSWindowActor/head.js b/dom/ipc/tests/JSWindowActor/head.js index 3448428f5f55..00c327c1a76d 100644 --- a/dom/ipc/tests/JSWindowActor/head.js +++ b/dom/ipc/tests/JSWindowActor/head.js @@ -8,30 +8,15 @@ const URL = "about:blank"; const TEST_URL = "http://test2.example.org/"; let windowActorOptions = { - jsm: { - parent: { - moduleURI: "resource://testing-common/TestWindowParent.jsm", - }, - child: { - moduleURI: "resource://testing-common/TestWindowChild.jsm", - }, + parent: { + moduleURI: "resource://testing-common/TestWindowParent.jsm", }, - "sys.mjs": { - parent: { - esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs", - }, - child: { - esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs", - }, + child: { + moduleURI: "resource://testing-common/TestWindowChild.jsm", }, }; function declTest(name, cfg) { - declTestWithOptions(name, cfg, "jsm"); - declTestWithOptions(name, cfg, "sys.mjs"); -} - -function declTestWithOptions(name, cfg, fileExt) { let { url = "about:blank", allFrames = false, @@ -47,8 +32,8 @@ function declTestWithOptions(name, cfg, fileExt) { // Build the actor options object which will be used to register & unregister // our window actor. let actorOptions = { - parent: { ...windowActorOptions[fileExt].parent }, - child: { ...windowActorOptions[fileExt].child, events, observers }, + parent: { ...windowActorOptions.parent }, + child: { ...windowActorOptions.child, events, observers }, }; actorOptions.allFrames = allFrames; actorOptions.includeChrome = includeChrome; @@ -71,7 +56,7 @@ function declTestWithOptions(name, cfg, fileExt) { try { await BrowserTestUtils.withNewTab(url, async browser => { info("browser ready"); - await Promise.resolve(test(browser, window, fileExt)); + await Promise.resolve(test(browser, window)); }); } finally { // Unregister the actor after the test is complete. diff --git a/js/xpconnect/idl/xpccomponents.idl b/js/xpconnect/idl/xpccomponents.idl index 18cf97780c18..47a4e4f41a75 100644 --- a/js/xpconnect/idl/xpccomponents.idl +++ b/js/xpconnect/idl/xpccomponents.idl @@ -213,8 +213,8 @@ interface nsIXPCComponents_Utils : nsISupports jsval import(in AUTF8String aResourceURI, [optional] in jsval targetObj); /** - * Returns true if the JSM is loaded into the system global previously via - * the import method above, or corresponding ESM is loaded. Returns false + * Returns true if the js file located at 'registryLocation' location has + * been loaded previously via the import method above. Returns false * otherwise. * * @param resourceURI A resource:// URI string representing the location of @@ -224,19 +224,6 @@ interface nsIXPCComponents_Utils : nsISupports */ boolean isModuleLoaded(in AUTF8String aResourceURI); - - /** - * Returns true if the JSM is loaded into the system global previously via - * the import method above. Returns false otherwise. - */ - boolean isJSModuleLoaded(in AUTF8String aResourceURI); - - /** - * Returns true if the ESM is loaded into the system global previously via - * the ChromeUtils.importESModule method etc. Returns false otherwise. - */ - boolean isESModuleLoaded(in AUTF8String aResourceURI); - /* * Unloads the JS module at 'registryLocation'. Existing references to the * module will continue to work but any subsequent import of the module will @@ -720,19 +707,9 @@ interface nsIXPCComponents_Utils : nsISupports // These attributes are for startup testing purposes. They are not expected // to be used for production code. - - // Array of the URI of JSM and ESM loaded, converting ESM URI into JSM URI. readonly attribute Array loadedModules; - readonly attribute Array loadedComponents; - // Array of the URI of JSM loaded. - readonly attribute Array loadedJSModules; - - // Array of the URI of ESM loaded. - readonly attribute Array loadedESModules; - - // These 2 functions will only return useful values if the // "browser.startup.record" preference was true at the time the JS file // was loaded. diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 150f60acaa26..3260279622c6 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -1188,40 +1188,6 @@ nsresult mozJSComponentLoader::IsModuleLoaded(const nsACString& aLocation, return NS_OK; } -nsresult mozJSComponentLoader::IsJSModuleLoaded(const nsACString& aLocation, - bool* retval) { - MOZ_ASSERT(nsContentUtils::IsCallerChrome()); - - mInitialized = true; - ComponentLoaderInfo info(aLocation); - if (mImports.Get(info.Key())) { - *retval = true; - return NS_OK; - } - - *retval = false; - return NS_OK; -} - -nsresult mozJSComponentLoader::IsESModuleLoaded(const nsACString& aLocation, - bool* retval) { - MOZ_ASSERT(nsContentUtils::IsCallerChrome()); - - mInitialized = true; - ComponentLoaderInfo info(aLocation); - - nsresult rv = info.EnsureURI(); - NS_ENSURE_SUCCESS(rv, rv); - - if (mModuleLoader->IsModuleFetched(info.URI())) { - *retval = true; - return NS_OK; - } - - *retval = false; - return NS_OK; -} - void mozJSComponentLoader::GetLoadedModules( nsTArray& aLoadedModules) { aLoadedModules.SetCapacity(mImports.Count()); diff --git a/js/xpconnect/loader/mozJSComponentLoader.h b/js/xpconnect/loader/mozJSComponentLoader.h index aa90dbe1e535..b2ba78ccb96f 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.h +++ b/js/xpconnect/loader/mozJSComponentLoader.h @@ -92,8 +92,6 @@ class mozJSComponentLoader final : public nsIMemoryReporter { nsresult Unload(const nsACString& aResourceURI); nsresult IsModuleLoaded(const nsACString& aResourceURI, bool* aRetval); - nsresult IsJSModuleLoaded(const nsACString& aResourceURI, bool* aRetval); - nsresult IsESModuleLoaded(const nsACString& aResourceURI, bool* aRetval); bool IsLoaderGlobal(JSObject* aObj) { return mLoaderGlobal == aObj; } // Public methods for use from ComponentModuleLoader. diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 81ace76a422b..3b67d953ea91 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -1561,27 +1561,11 @@ nsXPCComponents_Utils::Import(const nsACString& registryLocation, } NS_IMETHODIMP -nsXPCComponents_Utils::IsModuleLoaded(const nsACString& aResourceURI, +nsXPCComponents_Utils::IsModuleLoaded(const nsACString& registryLocation, bool* retval) { RefPtr moduleloader = mozJSComponentLoader::Get(); MOZ_ASSERT(moduleloader); - return moduleloader->IsModuleLoaded(aResourceURI, retval); -} - -NS_IMETHODIMP -nsXPCComponents_Utils::IsJSModuleLoaded(const nsACString& aResourceURI, - bool* retval) { - RefPtr moduleloader = mozJSComponentLoader::Get(); - MOZ_ASSERT(moduleloader); - return moduleloader->IsJSModuleLoaded(aResourceURI, retval); -} - -NS_IMETHODIMP -nsXPCComponents_Utils::IsESModuleLoaded(const nsACString& aResourceURI, - bool* retval) { - RefPtr moduleloader = mozJSComponentLoader::Get(); - MOZ_ASSERT(moduleloader); - return moduleloader->IsESModuleLoaded(aResourceURI, retval); + return moduleloader->IsModuleLoaded(registryLocation, retval); } NS_IMETHODIMP @@ -2548,19 +2532,6 @@ nsXPCComponents_Utils::GetLoadedComponents( return NS_OK; } -NS_IMETHODIMP -nsXPCComponents_Utils::GetLoadedJSModules( - nsTArray& aLoadedJSModules) { - mozJSComponentLoader::Get()->GetLoadedModules(aLoadedJSModules); - return NS_OK; -} - -NS_IMETHODIMP -nsXPCComponents_Utils::GetLoadedESModules( - nsTArray& aLoadedESModules) { - return mozJSComponentLoader::Get()->GetLoadedESModules(aLoadedESModules); -} - NS_IMETHODIMP nsXPCComponents_Utils::GetModuleImportStack(const nsACString& aLocation, nsACString& aRetval) { diff --git a/js/xpconnect/tests/unit/es6module_loaded-1.sys.mjs b/js/xpconnect/tests/unit/es6module_loaded-1.sys.mjs deleted file mode 100644 index e405565d6f4b..000000000000 --- a/js/xpconnect/tests/unit/es6module_loaded-1.sys.mjs +++ /dev/null @@ -1 +0,0 @@ -export function test() {} diff --git a/js/xpconnect/tests/unit/es6module_loaded-2.sys.mjs b/js/xpconnect/tests/unit/es6module_loaded-2.sys.mjs deleted file mode 100644 index e405565d6f4b..000000000000 --- a/js/xpconnect/tests/unit/es6module_loaded-2.sys.mjs +++ /dev/null @@ -1 +0,0 @@ -export function test() {} diff --git a/js/xpconnect/tests/unit/es6module_loaded-3.sys.mjs b/js/xpconnect/tests/unit/es6module_loaded-3.sys.mjs deleted file mode 100644 index e405565d6f4b..000000000000 --- a/js/xpconnect/tests/unit/es6module_loaded-3.sys.mjs +++ /dev/null @@ -1 +0,0 @@ -export function test() {} diff --git a/js/xpconnect/tests/unit/esm_lazy-1.sys.mjs b/js/xpconnect/tests/unit/esm_lazy-1.sys.mjs deleted file mode 100644 index a995420a56ec..000000000000 --- a/js/xpconnect/tests/unit/esm_lazy-1.sys.mjs +++ /dev/null @@ -1,4 +0,0 @@ -export let X = 10; -function GetX() { - return X; -} diff --git a/js/xpconnect/tests/unit/esm_lazy-2.sys.mjs b/js/xpconnect/tests/unit/esm_lazy-2.sys.mjs deleted file mode 100644 index 49410b61873e..000000000000 --- a/js/xpconnect/tests/unit/esm_lazy-2.sys.mjs +++ /dev/null @@ -1,4 +0,0 @@ -export let Y = 20; -export function AddY(n) { - Y += n; -}; diff --git a/js/xpconnect/tests/unit/jsm_loaded-1.jsm b/js/xpconnect/tests/unit/jsm_loaded-1.jsm deleted file mode 100644 index 9f12c255669a..000000000000 --- a/js/xpconnect/tests/unit/jsm_loaded-1.jsm +++ /dev/null @@ -1,2 +0,0 @@ -function test() {} -var EXPORTED_SYMBOLS = ["test"]; diff --git a/js/xpconnect/tests/unit/jsm_loaded-2.jsm b/js/xpconnect/tests/unit/jsm_loaded-2.jsm deleted file mode 100644 index 9f12c255669a..000000000000 --- a/js/xpconnect/tests/unit/jsm_loaded-2.jsm +++ /dev/null @@ -1,2 +0,0 @@ -function test() {} -var EXPORTED_SYMBOLS = ["test"]; diff --git a/js/xpconnect/tests/unit/jsm_loaded-3.jsm b/js/xpconnect/tests/unit/jsm_loaded-3.jsm deleted file mode 100644 index 9f12c255669a..000000000000 --- a/js/xpconnect/tests/unit/jsm_loaded-3.jsm +++ /dev/null @@ -1,2 +0,0 @@ -function test() {} -var EXPORTED_SYMBOLS = ["test"]; diff --git a/js/xpconnect/tests/unit/test_defineESModuleGetters.js b/js/xpconnect/tests/unit/test_defineESModuleGetters.js deleted file mode 100644 index f7f12de1d942..000000000000 --- a/js/xpconnect/tests/unit/test_defineESModuleGetters.js +++ /dev/null @@ -1,76 +0,0 @@ -function assertAccessor(lazy, name) { - let desc = Object.getOwnPropertyDescriptor(lazy, name); - Assert.equal(typeof desc.get, "function"); - Assert.equal(desc.get.name, name); - Assert.equal(typeof desc.set, "function"); - Assert.equal(desc.set.name, name); - Assert.equal(desc.enumerable, true); - Assert.equal(desc.configurable, true); -} - -function assertDataProperty(lazy, name, value) { - let desc = Object.getOwnPropertyDescriptor(lazy, name); - Assert.equal(desc.value, value); - Assert.equal(desc.writable, true); - Assert.equal(desc.enumerable, true); - Assert.equal(desc.configurable, true); -} - -add_task(function test_getter() { - // The property should be defined as getter, and getting it should make it - // a data property. - - const lazy = {}; - ChromeUtils.defineESModuleGetters(lazy, { - X: "resource://test/esm_lazy-1.sys.mjs", - }); - - assertAccessor(lazy, "X"); - - Assert.equal(lazy.X, 10); - assertDataProperty(lazy, "X", 10); -}); - -add_task(function test_setter() { - // Setting the value before the first get should result in a data property. - const lazy = {}; - ChromeUtils.defineESModuleGetters(lazy, { - X: "resource://test/esm_lazy-1.sys.mjs", - }); - - assertAccessor(lazy, "X"); - lazy.X = 20; - Assert.equal(lazy.X, 20); - assertDataProperty(lazy, "X", 20); - - // The above set shouldn't affect the module's value. - const lazy2 = {}; - ChromeUtils.defineESModuleGetters(lazy2, { - X: "resource://test/esm_lazy-1.sys.mjs", - }); - - Assert.equal(lazy2.X, 10); -}); - -add_task(function test_order() { - // The change to the exported value should be reflected until it's accessed. - - const lazy = {}; - ChromeUtils.defineESModuleGetters(lazy, { - Y: "resource://test/esm_lazy-2.sys.mjs", - AddY: "resource://test/esm_lazy-2.sys.mjs", - }); - - assertAccessor(lazy, "Y"); - assertAccessor(lazy, "AddY"); - - // The change before getting the value should be reflected. - lazy.AddY(2); - Assert.equal(lazy.Y, 22); - assertDataProperty(lazy, "Y", 22); - - // Change after getting the value shouldn't be reflected. - lazy.AddY(2); - Assert.equal(lazy.Y, 22); - assertDataProperty(lazy, "Y", 22); -}); diff --git a/js/xpconnect/tests/unit/test_loadedESModules.js b/js/xpconnect/tests/unit/test_loadedESModules.js deleted file mode 100644 index 00e10590370e..000000000000 --- a/js/xpconnect/tests/unit/test_loadedESModules.js +++ /dev/null @@ -1,127 +0,0 @@ -add_task(function test_JSModule() { - const URL1 = "resource://test/jsm_loaded-1.jsm"; - const URL2 = "resource://test/jsm_loaded-2.jsm"; - const URL3 = "resource://test/jsm_loaded-3.jsm"; - - Assert.ok(!Cu.loadedJSModules.includes(URL1)); - Assert.ok(!Cu.isJSModuleLoaded(URL1)); - Assert.ok(!Cu.loadedJSModules.includes(URL2)); - Assert.ok(!Cu.isJSModuleLoaded(URL2)); - Assert.ok(!Cu.loadedJSModules.includes(URL3)); - Assert.ok(!Cu.isJSModuleLoaded(URL3)); - Assert.ok(!Cu.loadedESModules.includes(URL1)); - Assert.ok(!Cu.isESModuleLoaded(URL1)); - Assert.ok(!Cu.loadedESModules.includes(URL2)); - Assert.ok(!Cu.isESModuleLoaded(URL2)); - Assert.ok(!Cu.loadedESModules.includes(URL3)); - Assert.ok(!Cu.isESModuleLoaded(URL3)); - - ChromeUtils.import(URL1); - - Assert.ok(Cu.loadedJSModules.includes(URL1)); - Assert.ok(Cu.isJSModuleLoaded(URL1)); - Assert.ok(!Cu.loadedJSModules.includes(URL2)); - Assert.ok(!Cu.isJSModuleLoaded(URL2)); - Assert.ok(!Cu.loadedJSModules.includes(URL3)); - Assert.ok(!Cu.isJSModuleLoaded(URL3)); - Assert.ok(!Cu.loadedESModules.includes(URL1)); - Assert.ok(!Cu.isESModuleLoaded(URL1)); - Assert.ok(!Cu.loadedESModules.includes(URL2)); - Assert.ok(!Cu.isESModuleLoaded(URL2)); - Assert.ok(!Cu.loadedESModules.includes(URL3)); - Assert.ok(!Cu.isESModuleLoaded(URL3)); - - ChromeUtils.import(URL2); - - Assert.ok(Cu.loadedJSModules.includes(URL1)); - Assert.ok(Cu.isJSModuleLoaded(URL1)); - Assert.ok(Cu.loadedJSModules.includes(URL2)); - Assert.ok(Cu.isJSModuleLoaded(URL2)); - Assert.ok(!Cu.loadedJSModules.includes(URL3)); - Assert.ok(!Cu.isJSModuleLoaded(URL3)); - Assert.ok(!Cu.loadedESModules.includes(URL1)); - Assert.ok(!Cu.isESModuleLoaded(URL1)); - Assert.ok(!Cu.loadedESModules.includes(URL2)); - Assert.ok(!Cu.isESModuleLoaded(URL2)); - Assert.ok(!Cu.loadedESModules.includes(URL3)); - Assert.ok(!Cu.isESModuleLoaded(URL3)); - - ChromeUtils.import(URL3); - - Assert.ok(Cu.loadedJSModules.includes(URL1)); - Assert.ok(Cu.isJSModuleLoaded(URL1)); - Assert.ok(Cu.loadedJSModules.includes(URL2)); - Assert.ok(Cu.isJSModuleLoaded(URL2)); - Assert.ok(Cu.loadedJSModules.includes(URL3)); - Assert.ok(Cu.isJSModuleLoaded(URL3)); - Assert.ok(!Cu.loadedESModules.includes(URL1)); - Assert.ok(!Cu.isESModuleLoaded(URL1)); - Assert.ok(!Cu.loadedESModules.includes(URL2)); - Assert.ok(!Cu.isESModuleLoaded(URL2)); - Assert.ok(!Cu.loadedESModules.includes(URL3)); - Assert.ok(!Cu.isESModuleLoaded(URL3)); -}); - -add_task(function test_ESModule() { - const URL1 = "resource://test/es6module_loaded-1.sys.mjs"; - const URL2 = "resource://test/es6module_loaded-2.sys.mjs"; - const URL3 = "resource://test/es6module_loaded-3.sys.mjs"; - - Assert.ok(!Cu.loadedJSModules.includes(URL1)); - Assert.ok(!Cu.isJSModuleLoaded(URL1)); - Assert.ok(!Cu.loadedJSModules.includes(URL2)); - Assert.ok(!Cu.isJSModuleLoaded(URL2)); - Assert.ok(!Cu.loadedJSModules.includes(URL3)); - Assert.ok(!Cu.isJSModuleLoaded(URL3)); - Assert.ok(!Cu.loadedESModules.includes(URL1)); - Assert.ok(!Cu.isESModuleLoaded(URL1)); - Assert.ok(!Cu.loadedESModules.includes(URL2)); - Assert.ok(!Cu.isESModuleLoaded(URL2)); - Assert.ok(!Cu.loadedESModules.includes(URL3)); - Assert.ok(!Cu.isESModuleLoaded(URL3)); - - ChromeUtils.importESModule(URL1); - - Assert.ok(!Cu.loadedJSModules.includes(URL1)); - Assert.ok(!Cu.isJSModuleLoaded(URL1)); - Assert.ok(!Cu.loadedJSModules.includes(URL2)); - Assert.ok(!Cu.isJSModuleLoaded(URL2)); - Assert.ok(!Cu.loadedJSModules.includes(URL3)); - Assert.ok(!Cu.isJSModuleLoaded(URL3)); - Assert.ok(Cu.loadedESModules.includes(URL1)); - Assert.ok(Cu.isESModuleLoaded(URL1)); - Assert.ok(!Cu.loadedESModules.includes(URL2)); - Assert.ok(!Cu.isESModuleLoaded(URL2)); - Assert.ok(!Cu.loadedESModules.includes(URL3)); - Assert.ok(!Cu.isESModuleLoaded(URL3)); - - ChromeUtils.importESModule(URL2); - - Assert.ok(!Cu.loadedJSModules.includes(URL1)); - Assert.ok(!Cu.isJSModuleLoaded(URL1)); - Assert.ok(!Cu.loadedJSModules.includes(URL2)); - Assert.ok(!Cu.isJSModuleLoaded(URL2)); - Assert.ok(!Cu.loadedJSModules.includes(URL3)); - Assert.ok(!Cu.isJSModuleLoaded(URL3)); - Assert.ok(Cu.loadedESModules.includes(URL1)); - Assert.ok(Cu.isESModuleLoaded(URL1)); - Assert.ok(Cu.loadedESModules.includes(URL2)); - Assert.ok(Cu.isESModuleLoaded(URL2)); - Assert.ok(!Cu.loadedESModules.includes(URL3)); - Assert.ok(!Cu.isESModuleLoaded(URL3)); - - ChromeUtils.importESModule(URL3); - - Assert.ok(!Cu.loadedJSModules.includes(URL1)); - Assert.ok(!Cu.isJSModuleLoaded(URL1)); - Assert.ok(!Cu.loadedJSModules.includes(URL2)); - Assert.ok(!Cu.isJSModuleLoaded(URL2)); - Assert.ok(!Cu.loadedJSModules.includes(URL3)); - Assert.ok(!Cu.isJSModuleLoaded(URL3)); - Assert.ok(Cu.loadedESModules.includes(URL1)); - Assert.ok(Cu.isESModuleLoaded(URL1)); - Assert.ok(Cu.loadedESModules.includes(URL2)); - Assert.ok(Cu.isESModuleLoaded(URL2)); - Assert.ok(Cu.loadedESModules.includes(URL3)); - Assert.ok(Cu.isESModuleLoaded(URL3)); -}); diff --git a/js/xpconnect/tests/unit/xpcshell.ini b/js/xpconnect/tests/unit/xpcshell.ini index 8dc163a66363..c4e453902c5f 100644 --- a/js/xpconnect/tests/unit/xpcshell.ini +++ b/js/xpconnect/tests/unit/xpcshell.ini @@ -36,14 +36,6 @@ support-files = esmified-6.sys.mjs esmified-not-exported.sys.mjs not-esmified-not-exported.jsm - esm_lazy-1.sys.mjs - esm_lazy-2.sys.mjs - jsm_loaded-1.jsm - jsm_loaded-2.jsm - jsm_loaded-3.jsm - es6module_loaded-1.sys.mjs - es6module_loaded-2.sys.mjs - es6module_loaded-3.sys.mjs [test_allowWaivers.js] [test_bogus_files.js] @@ -188,5 +180,3 @@ head = head_watchdog.js [test_print_stderr.js] [test_import_es6_modules.js] [test_import_shim.js] -[test_defineESModuleGetters.js] -[test_loadedESModules.js] diff --git a/toolkit/actors/TestProcessActorChild.sys.mjs b/toolkit/actors/TestProcessActorChild.sys.mjs deleted file mode 100644 index b5af783e3ada..000000000000 --- a/toolkit/actors/TestProcessActorChild.sys.mjs +++ /dev/null @@ -1,60 +0,0 @@ -/* vim: set ts=2 sw=2 sts=2 et tw=80: */ -/* 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"; - -const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); - -// eslint-disable-next-line import/prefer-default-export -export class TestProcessActorChild extends JSProcessActorChild { - constructor() { - super(); - this.sawActorCreated = false; - } - - actorCreated() { - this.sawActorCreated = true; - } - - receiveMessage(aMessage) { - switch (aMessage.name) { - case "toChild": - aMessage.data.toChild = true; - this.sendAsyncMessage("toParent", aMessage.data); - break; - case "asyncAdd": - let { a, b } = aMessage.data; - return new Promise(resolve => { - resolve({ result: a + b }); - }); - case "error": - return Promise.reject(new SyntaxError(aMessage.data.message)); - case "exception": - return Promise.reject( - Components.Exception(aMessage.data.message, aMessage.data.result) - ); - case "done": - this.done(aMessage.data); - break; - } - - return undefined; - } - - observe(subject, topic, data) { - this.lastObserved = { subject, topic, data }; - } - - show() { - return "TestProcessActorChild"; - } - - didDestroy() { - Services.obs.notifyObservers( - this, - "test-js-content-actor-diddestroy", - true - ); - } -} diff --git a/toolkit/actors/TestProcessActorParent.sys.mjs b/toolkit/actors/TestProcessActorParent.sys.mjs deleted file mode 100644 index bc2c347c2643..000000000000 --- a/toolkit/actors/TestProcessActorParent.sys.mjs +++ /dev/null @@ -1,40 +0,0 @@ -/* vim: set ts=2 sw=2 sts=2 et tw=80: */ -/* 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"; - -// eslint-disable-next-line import/prefer-default-export -export class TestProcessActorParent extends JSProcessActorParent { - constructor() { - super(); - this.wrappedJSObject = this; - this.sawActorCreated = false; - } - - actorCreated() { - this.sawActorCreated = true; - } - - receiveMessage(aMessage) { - switch (aMessage.name) { - case "init": - aMessage.data.initial = true; - this.sendAsyncMessage("toChild", aMessage.data); - break; - case "toParent": - aMessage.data.toParent = true; - this.sendAsyncMessage("done", aMessage.data); - break; - case "asyncMul": - let { a, b } = aMessage.data; - return { result: a * b }; - } - - return undefined; - } - - show() { - return "TestProcessActorParent"; - } -} diff --git a/toolkit/actors/TestWindowChild.sys.mjs b/toolkit/actors/TestWindowChild.sys.mjs deleted file mode 100644 index c04099bcbb34..000000000000 --- a/toolkit/actors/TestWindowChild.sys.mjs +++ /dev/null @@ -1,103 +0,0 @@ -/* vim: set ts=2 sw=2 sts=2 et tw=80: */ -/* 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"; - -const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); - -var docShellThunks = new Map(); - -// eslint-disable-next-line import/prefer-default-export -export class TestWindowChild extends JSWindowActorChild { - constructor() { - super(); - this.sawActorCreated = false; - - try { - void this.contentWindow; - } catch (e) { - this.uninitializedGetterError = e; - } - } - - actorCreated() { - this.sawActorCreated = true; - } - - receiveMessage(aMessage) { - switch (aMessage.name) { - case "toChild": - aMessage.data.toChild = true; - this.sendAsyncMessage("toParent", aMessage.data); - break; - case "asyncAdd": - let { a, b } = aMessage.data; - return new Promise(resolve => { - resolve({ result: a + b }); - }); - case "error": - return Promise.reject(new SyntaxError(aMessage.data.message)); - case "exception": - return Promise.reject( - Components.Exception(aMessage.data.message, aMessage.data.result) - ); - case "done": - this.done(aMessage.data); - break; - case "noncloneReply": - // Return a value which is non-cloneable, like a WindowProxy. - return this.contentWindow; - case "storeActor": - docShellThunks.set(this.docShell, this); - break; - case "checkActor": { - let actor = docShellThunks.get(this.docShell); - docShellThunks.delete(this.docShell); - - let contentWindow; - let error; - try { - contentWindow = actor.contentWindow; - } catch (e) { - error = e; - } - if (error) { - return { - status: "error", - errorType: error.name, - }; - } - return { - status: "success", - valueIsNull: contentWindow === null, - }; - } - } - - return undefined; - } - - handleEvent(aEvent) { - this.sendAsyncMessage("event", { type: aEvent.type }); - } - - observe(subject, topic, data) { - switch (topic) { - case "audio-playback": - this.done({ subject, topic, data }); - break; - default: - this.lastObserved = { subject, topic, data }; - break; - } - } - - show() { - return "TestWindowChild"; - } - - didDestroy() { - Services.obs.notifyObservers(this, "test-js-window-actor-diddestroy", true); - } -} diff --git a/toolkit/actors/TestWindowParent.sys.mjs b/toolkit/actors/TestWindowParent.sys.mjs deleted file mode 100644 index 50709225df02..000000000000 --- a/toolkit/actors/TestWindowParent.sys.mjs +++ /dev/null @@ -1,50 +0,0 @@ -/* vim: set ts=2 sw=2 sts=2 et tw=80: */ -/* 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"; - -const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); - -// eslint-disable-next-line import/prefer-default-export -export class TestWindowParent extends JSWindowActorParent { - constructor() { - super(); - this.wrappedJSObject = this; - this.sawActorCreated = false; - } - - actorCreated() { - this.sawActorCreated = true; - } - - receiveMessage(aMessage) { - switch (aMessage.name) { - case "init": - aMessage.data.initial = true; - this.sendAsyncMessage("toChild", aMessage.data); - break; - case "toParent": - aMessage.data.toParent = true; - this.sendAsyncMessage("done", aMessage.data); - break; - case "asyncMul": - let { a, b } = aMessage.data; - return { result: a * b }; - - case "event": - Services.obs.notifyObservers( - this, - "test-js-window-actor-parent-event", - aMessage.data.type - ); - break; - } - - return undefined; - } - - show() { - return "TestWindowParent"; - } -} diff --git a/toolkit/actors/moz.build b/toolkit/actors/moz.build index 874bd25577f7..8b74ddda9655 100644 --- a/toolkit/actors/moz.build +++ b/toolkit/actors/moz.build @@ -23,13 +23,9 @@ SPHINX_TREES["actors"] = "docs" TESTING_JS_MODULES += [ "TestProcessActorChild.jsm", - "TestProcessActorChild.sys.mjs", "TestProcessActorParent.jsm", - "TestProcessActorParent.sys.mjs", "TestWindowChild.jsm", - "TestWindowChild.sys.mjs", "TestWindowParent.jsm", - "TestWindowParent.sys.mjs", ] FINAL_TARGET_FILES.actors += [ diff --git a/toolkit/components/utils/SimpleServices.sys.mjs b/toolkit/components/utils/SimpleServices.jsm similarity index 97% rename from toolkit/components/utils/SimpleServices.sys.mjs rename to toolkit/components/utils/SimpleServices.jsm index 00d5dc897601..b14deb8c2e46 100644 --- a/toolkit/components/utils/SimpleServices.sys.mjs +++ b/toolkit/components/utils/SimpleServices.jsm @@ -14,7 +14,6 @@ /* globals WebExtensionPolicy */ -const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); @@ -26,6 +25,7 @@ ChromeUtils.defineModuleGetter( "NetUtil", "resource://gre/modules/NetUtil.jsm" ); +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyServiceGetter( lazy, @@ -46,7 +46,7 @@ const ArrayBufferInputStream = Components.Constructor( * See SubstituteChannel in netwerk/protocol/res/ExtensionProtocolHandler.cpp * for usage. */ -export function AddonLocalizationConverter() {} +function AddonLocalizationConverter() {} AddonLocalizationConverter.prototype = { QueryInterface: ChromeUtils.generateQI(["nsIStreamConverter"]), @@ -137,7 +137,7 @@ AddonLocalizationConverter.prototype = { }, }; -export function HttpIndexViewer() {} +function HttpIndexViewer() {} HttpIndexViewer.prototype = { QueryInterface: ChromeUtils.generateQI(["nsIDocumentLoaderFactory"]), @@ -180,3 +180,5 @@ HttpIndexViewer.prototype = { return res; }, }; + +var EXPORTED_SYMBOLS = ["AddonLocalizationConverter", "HttpIndexViewer"]; diff --git a/toolkit/components/utils/components.conf b/toolkit/components/utils/components.conf index 365138507e27..595381b8e09f 100644 --- a/toolkit/components/utils/components.conf +++ b/toolkit/components/utils/components.conf @@ -8,13 +8,13 @@ Classes = [ { 'cid': '{ded150e3-c92e-4077-a396-0dba9953e39f}', 'contract_ids': ['@mozilla.org/streamconv;1?from=application/vnd.mozilla.webext.unlocalized&to=text/css'], - 'esModule': 'resource://gre/modules/SimpleServices.sys.mjs', + 'jsm': 'resource://gre/modules/SimpleServices.jsm', 'constructor': 'AddonLocalizationConverter', }, { 'cid': '{742ad274-34c5-43d1-a8b7-293eaf8962d6}', 'contract_ids': ['@mozilla.org/content-viewers/http-index-format'], - 'esModule': 'resource://gre/modules/SimpleServices.sys.mjs', + 'jsm': 'resource://gre/modules/SimpleServices.jsm', 'constructor': 'HttpIndexViewer', 'categories': {'Gecko-Content-Viewers': 'application/http-index-format'}, }, diff --git a/toolkit/components/utils/moz.build b/toolkit/components/utils/moz.build index 9dcd7debdd2e..d2028de02a57 100644 --- a/toolkit/components/utils/moz.build +++ b/toolkit/components/utils/moz.build @@ -8,7 +8,7 @@ with Files("**"): BUG_COMPONENT = ("Toolkit", "General") EXTRA_JS_MODULES += [ - "SimpleServices.sys.mjs", + "SimpleServices.jsm", ] EXTRA_JS_MODULES["components-utils"] = [ diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js index a429933aff77..3faf1cf60d64 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js @@ -50,7 +50,6 @@ module.exports = { }, files: ["**/*.sys.mjs", "**/*.jsm", "**/*.jsm.js"], rules: { - "mozilla/lazy-getter-object-name": "error", "mozilla/reject-global-this": "error", "mozilla/reject-globalThis-modification": "error", "mozilla/reject-top-level-await": "error", diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js index 5918b4ad069d..87e9235b59f5 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js @@ -39,7 +39,6 @@ module.exports = { "import-content-task-globals": require("../lib/rules/import-content-task-globals"), "import-globals": require("../lib/rules/import-globals"), "import-headjs-globals": require("../lib/rules/import-headjs-globals"), - "lazy-getter-object-name": require("../lib/rules/lazy-getter-object-name"), "mark-exported-symbols-as-used": require("../lib/rules/mark-exported-symbols-as-used"), "mark-test-function-used": require("../lib/rules/mark-test-function-used"), "no-aArgs": require("../lib/rules/no-aArgs"), diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/lazy-getter-object-name.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/lazy-getter-object-name.js deleted file mode 100644 index 4b4e807140b1..000000000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/lazy-getter-object-name.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @fileoverview Enforce the standard object name for - * ChromeUtils.defineESModuleGetters - * - * 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"; - -function isIdentifier(node, id) { - return node.type === "Identifier" && node.name === id; -} - -module.exports = { - meta: { - docs: { - url: - "https://firefox-source-docs.mozilla.org/code-quality/lint/linters/eslint-plugin-mozilla/lazy-getter-object-name.html", - }, - type: "problem", - }, - - create(context) { - return { - CallExpression(node) { - let { callee } = node; - if ( - callee.type === "MemberExpression" && - isIdentifier(callee.object, "ChromeUtils") && - isIdentifier(callee.property, "defineESModuleGetters") && - node.arguments.length >= 1 && - !isIdentifier(node.arguments[0], "lazy") - ) { - context.report({ - node, - message: - "The variable name of the object passed to ChromeUtils.defineESModuleGetters must be `lazy`", - }); - } - }, - }; - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/lazy-getter-object-name.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/lazy-getter-object-name.js deleted file mode 100644 index 203bf5079de4..000000000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/tests/lazy-getter-object-name.js +++ /dev/null @@ -1,50 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -// ------------------------------------------------------------------------------ -// Requirements -// ------------------------------------------------------------------------------ - -var rule = require("../lib/rules/lazy-getter-object-name"); -var RuleTester = require("eslint").RuleTester; - -const ruleTester = new RuleTester(); - -// ------------------------------------------------------------------------------ -// Tests -// ------------------------------------------------------------------------------ - -function invalidCode(code) { - let message = - "The variable name of the object passed to ChromeUtils.defineESModuleGetters must be `lazy`"; - return { code, errors: [{ message, type: "CallExpression" }] }; -} - -ruleTester.run("lazy-getter-object-name", rule, { - valid: [ - ` - ChromeUtils.defineESModuleGetters(lazy, { - Services: "resource://gre/modules/Services.sys.mjs", - }); -`, - ], - invalid: [ - invalidCode(` - ChromeUtils.defineESModuleGetters(obj, { - Services: "resource://gre/modules/Services.sys.mjs", - }); -`), - invalidCode(` - ChromeUtils.defineESModuleGetters(this, { - Services: "resource://gre/modules/Services.sys.mjs", - }); -`), - invalidCode(` - ChromeUtils.defineESModuleGetters(window, { - Services: "resource://gre/modules/Services.sys.mjs", - }); -`), - ], -}); diff --git a/xpcom/components/StaticComponents.cpp.in b/xpcom/components/StaticComponents.cpp.in index 0aedb3037cf3..457b231c3559 100644 --- a/xpcom/components/StaticComponents.cpp.in +++ b/xpcom/components/StaticComponents.cpp.in @@ -87,10 +87,6 @@ const StringOffset gComponentJSMs[] = { //# @component_jsms@ }; -const StringOffset gComponentESModules[] = { -//# @component_esmodules@ -}; - /** * Returns a nsCString corresponding to the given entry in the `gStrings` string * table. The resulting nsCString points directly to static storage, and does @@ -111,12 +107,10 @@ bool ContractEntry::Matches(const nsACString& aContractID) const { return aContractID == ContractID() && Module().Active(); } -enum class ComponentType { JSM, ESM }; -template -static nsresult ConstructJSMOrESMComponent(const nsACString& aURI, - const char* aConstructor, - nsISupports** aResult) { +static nsresult ConstructJSMComponent(const nsACString& aURI, + const char* aConstructor, + nsISupports** aResult) { if (!nsComponentManagerImpl::JSLoaderReady()) { return NS_ERROR_NOT_AVAILABLE; } @@ -125,21 +119,17 @@ static nsresult ConstructJSMOrESMComponent(const nsACString& aURI, MOZ_ALWAYS_TRUE(jsapi.Init(xpc::PrivilegedJunkScope())); JSContext* cx = jsapi.cx(); - JS::Rooted exports(cx); - if constexpr (type == ComponentType::JSM) { - JS::Rooted global(cx); - MOZ_TRY(mozJSComponentLoader::Get()->Import(cx, aURI, &global, &exports)); - } else { - MOZ_TRY(mozJSComponentLoader::Get()->ImportESModule(cx, aURI, &exports)); - } + JS::RootedObject global(cx); + JS::RootedObject exports(cx); + MOZ_TRY(mozJSComponentLoader::Get()->Import(cx, aURI, &global, &exports)); - JS::Rooted ctor(cx); + JS::RootedValue ctor(cx); if (!JS_GetProperty(cx, exports, aConstructor, &ctor) || !ctor.isObject()) { return NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED; } - JS::Rooted inst(cx); + JS::RootedObject inst(cx); if (!JS::Construct(cx, ctor, JS::HandleValueArray::empty(), &inst)) { return NS_ERROR_FAILURE; } @@ -148,19 +138,6 @@ static nsresult ConstructJSMOrESMComponent(const nsACString& aURI, (void**)aResult); } -static nsresult ConstructJSMComponent(const nsACString& aURI, - const char* aConstructor, - nsISupports** aResult) { - return ConstructJSMOrESMComponent( - aURI, aConstructor, aResult); -} - -static nsresult ConstructESModuleComponent(const nsACString& aURI, - const char* aConstructor, - nsISupports** aResult) { - return ConstructJSMOrESMComponent( - aURI, aConstructor, aResult); -} //# @module_cid_table@ @@ -353,20 +330,6 @@ StaticComponents::GetComponentJSMs() { return result.forget(); } -/* static */ already_AddRefed -StaticComponents::GetComponentESModules() { - auto esModules = MakeUnique>(MOZ_ARRAY_LENGTH(gComponentESModules)); - - for (const auto& entry : gComponentESModules) { - esModules->AppendElement(GetString(entry)); - } - - nsCOMPtr result; - MOZ_ALWAYS_SUCCEEDS(NS_NewAdoptingUTF8StringEnumerator(getter_AddRefs(result), - esModules.release())); - return result.forget(); -} - /* static */ Span StaticComponents::GetJSServices() { return { gJSServices, ArrayLength(gJSServices) }; } diff --git a/xpcom/components/StaticComponents.h b/xpcom/components/StaticComponents.h index 3dea0a63895d..2b85b78537b6 100644 --- a/xpcom/components/StaticComponents.h +++ b/xpcom/components/StaticComponents.h @@ -243,7 +243,6 @@ class StaticComponents final { bool aInvalid = true); static already_AddRefed GetComponentJSMs(); - static already_AddRefed GetComponentESModules(); static Span GetJSServices(); diff --git a/xpcom/components/gen_static_components.py b/xpcom/components/gen_static_components.py index 50b8559abaaf..c2495e903e78 100644 --- a/xpcom/components/gen_static_components.py +++ b/xpcom/components/gen_static_components.py @@ -282,7 +282,6 @@ class ModuleEntry(object): self.init_method = data.get("init_method", []) self.jsm = data.get("jsm", None) - self.esModule = data.get("esModule", None) self.external = data.get( "external", not (self.headers or self.legacy_constructor) @@ -308,16 +307,6 @@ class ModuleEntry(object): if not self.constructor: error("JavaScript components must specify a constructor") - for prop in ("init_method", "legacy_constructor", "headers"): - if getattr(self, prop): - error( - "JavaScript components may not specify a '%s' " - "property" % prop - ) - elif self.esModule: - if not self.constructor: - error("JavaScript components must specify a constructor") - for prop in ("init_method", "legacy_constructor", "headers"): if getattr(self, prop): error( @@ -424,14 +413,6 @@ class ModuleEntry(object): " getter_AddRefs(inst)));" "\n" % (json.dumps(self.jsm), json.dumps(self.constructor)) ) - elif self.esModule: - res += ( - " nsCOMPtr inst;\n" - " MOZ_TRY(ConstructESModuleComponent(nsLiteralCString(%s),\n" - " %s,\n" - " getter_AddRefs(inst)));" - "\n" % (json.dumps(self.esModule), json.dumps(self.constructor)) - ) elif self.external: res += ( " nsCOMPtr inst = " @@ -762,7 +743,6 @@ def gen_substs(manifests): js_services = {} jsms = set() - esModules = set() types = set() @@ -787,9 +767,6 @@ def gen_substs(manifests): if mod.jsm: jsms.add(mod.jsm) - if mod.esModule: - esModules.add(mod.esModule) - if mod.js_name: if mod.js_name in js_services: raise Exception("Duplicate JS service name: %s" % mod.js_name) @@ -828,12 +805,6 @@ def gen_substs(manifests): substs["component_jsms"] = ( "\n".join(" %s," % strings.entry_to_cxx(jsm) for jsm in sorted(jsms)) + "\n" ) - substs["component_esmodules"] = ( - "\n".join( - " %s," % strings.entry_to_cxx(esModule) for esModule in sorted(esModules) - ) - + "\n" - ) substs["interfaces"] = gen_interfaces(interfaces) diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 41d9297dffa5..53fcecbf77fd 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -1877,15 +1877,6 @@ nsComponentManagerImpl::GetComponentJSMs(nsIUTF8StringEnumerator** aJSMs) { return NS_OK; } -NS_IMETHODIMP -nsComponentManagerImpl::GetComponentESModules( - nsIUTF8StringEnumerator** aESModules) { - nsCOMPtr result = - StaticComponents::GetComponentESModules(); - result.forget(aESModules); - return NS_OK; -} - NS_IMETHODIMP nsComponentManagerImpl::GetManifestLocations(nsIArray** aLocations) { NS_ENSURE_ARG_POINTER(aLocations); diff --git a/xpcom/components/nsIComponentManager.idl b/xpcom/components/nsIComponentManager.idl index 9abde9960c79..095ca47f107c 100644 --- a/xpcom/components/nsIComponentManager.idl +++ b/xpcom/components/nsIComponentManager.idl @@ -101,12 +101,6 @@ interface nsIComponentManager : nsISupports * should only be used in automation. */ nsIUTF8StringEnumerator getComponentJSMs(); - - /** - * Returns a list of ESM URLs which are used to create components. This - * should only be used in automation. - */ - nsIUTF8StringEnumerator getComponentESModules(); };