From 9a53dd3fa6981c87af9a10c217704bb001d3b3b3 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Tue, 21 Jan 2025 13:37:19 +0000 Subject: [PATCH] Bug 1881887 - Part 2: Remove support for component JSMs. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D233365 --- xpcom/components/StaticComponents.cpp.in | 57 ++--------------------- xpcom/components/StaticComponents.h | 1 - xpcom/components/gen_static_components.py | 33 +------------ xpcom/components/nsComponentManager.cpp | 8 ---- xpcom/components/nsIComponentManager.idl | 8 ---- 5 files changed, 6 insertions(+), 101 deletions(-) diff --git a/xpcom/components/StaticComponents.cpp.in b/xpcom/components/StaticComponents.cpp.in index 6f3db11e38a4..2248713d56e5 100644 --- a/xpcom/components/StaticComponents.cpp.in +++ b/xpcom/components/StaticComponents.cpp.in @@ -83,15 +83,6 @@ const nsXPTInterface gInterfaces[] = { //# @interfaces@ }; -//# @define_has_component_jsms@ - -#ifdef HAS_COMPONENT_JSMS -// TODO: Remove this once m-c and c-c migrations finish (bug 1881887). -const StringOffset gComponentJSMs[] = { -//# @component_jsms@ -}; -#endif - const StringOffset gComponentESModules[] = { //# @component_esmodules@ }; @@ -116,12 +107,9 @@ 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 ConstructESModuleComponent(const nsACString& aURI, + const char* aConstructor, + nsISupports** aResult) { if (!nsComponentManagerImpl::JSLoaderReady()) { return NS_ERROR_NOT_AVAILABLE; } @@ -131,12 +119,7 @@ static nsresult ConstructJSMOrESMComponent(const nsACString& aURI, JSContext* cx = jsapi.cx(); JS::Rooted exports(cx); - if constexpr (type == ComponentType::JSM) { - JS::Rooted global(cx); - MOZ_TRY(mozJSModuleLoader::Get()->Import(cx, aURI, &global, &exports)); - } else { - MOZ_TRY(mozJSModuleLoader::Get()->ImportESModule(cx, aURI, &exports)); - } + MOZ_TRY(mozJSModuleLoader::Get()->ImportESModule(cx, aURI, &exports)); JS::Rooted ctor(cx); if (!JS_GetProperty(cx, exports, aConstructor, &ctor) || @@ -153,20 +136,6 @@ static nsresult ConstructJSMOrESMComponent(const nsACString& aURI, (void**)aResult); } -[[maybe_unused]] 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@ //# @module_contract_id_table@ @@ -354,24 +323,6 @@ const StaticProtocolHandler* StaticProtocolHandler::Lookup(const nsACString& aSc return false; } -/* static */ already_AddRefed -StaticComponents::GetComponentJSMs() { -#ifdef HAS_COMPONENT_JSMS - auto jsms = MakeUnique>(std::size(gComponentJSMs)); - - for (const auto& entry : gComponentJSMs) { - jsms->AppendElement(GetString(entry)); - } -#else - auto jsms = MakeUnique>(0); -#endif - - nsCOMPtr result; - MOZ_ALWAYS_SUCCEEDS(NS_NewAdoptingUTF8StringEnumerator(getter_AddRefs(result), - jsms.release())); - return result.forget(); -} - /* static */ already_AddRefed StaticComponents::GetComponentESModules() { auto esModules = MakeUnique>(std::size(gComponentESModules)); diff --git a/xpcom/components/StaticComponents.h b/xpcom/components/StaticComponents.h index ac4095f2f35e..8fad9222cdde 100644 --- a/xpcom/components/StaticComponents.h +++ b/xpcom/components/StaticComponents.h @@ -267,7 +267,6 @@ class StaticComponents final { static bool InvalidateContractID(const nsACString& aContractID, 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 122b7b21ca5a..d9c28ff3290d 100644 --- a/xpcom/components/gen_static_components.py +++ b/xpcom/components/gen_static_components.py @@ -291,7 +291,6 @@ class ModuleEntry(object): self.legacy_constructor = data.get("legacy_constructor", None) self.init_method = data.get("init_method", []) - self.jsm = data.get("jsm", None) self.esModule = data.get("esModule", None) self.external = data.get( @@ -316,17 +315,7 @@ class ModuleEntry(object): % (str(self.cid), ", ".join(map(repr, self.contract_ids)), str_) ) - if self.jsm: - 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 self.esModule: if not self.constructor: error("JavaScript components must specify a constructor") @@ -428,15 +417,7 @@ class ModuleEntry(object): ) return res - if self.jsm: - res += ( - " nsCOMPtr inst;\n" - " MOZ_TRY(ConstructJSMComponent(nsLiteralCString(%s),\n" - " %s,\n" - " getter_AddRefs(inst)));" - "\n" % (json.dumps(self.jsm), json.dumps(self.constructor)) - ) - elif self.esModule: + if self.esModule: res += ( " nsCOMPtr inst;\n" " MOZ_TRY(ConstructESModuleComponent(nsLiteralCString(%s),\n" @@ -874,7 +855,6 @@ def gen_substs(manifests): js_services = {} protocol_handlers = {} - jsms = set() esModules = set() types = set() @@ -897,9 +877,6 @@ def gen_substs(manifests): if mod.type and not mod.headers: types.add(mod.type) - if mod.jsm: - jsms.add(mod.jsm) - if mod.esModule: esModules.add(mod.esModule) @@ -955,12 +932,6 @@ def gen_substs(manifests): gen_includes(substs, headers) - substs["component_jsms"] = ( - "\n".join(" %s," % strings.entry_to_cxx(jsm) for jsm in sorted(jsms)) + "\n" - ) - substs["define_has_component_jsms"] = ( - "#define HAS_COMPONENT_JSMS" if len(jsms) > 0 else "" - ) substs["component_esmodules"] = ( "\n".join( " %s," % strings.entry_to_cxx(esModule) for esModule in sorted(esModules) diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 3ca394ecc579..34de4b830324 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -1471,14 +1471,6 @@ nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsIFile* aLocation) { return rv; } -NS_IMETHODIMP -nsComponentManagerImpl::GetComponentJSMs(nsIUTF8StringEnumerator** aJSMs) { - nsCOMPtr result = - StaticComponents::GetComponentJSMs(); - result.forget(aJSMs); - return NS_OK; -} - NS_IMETHODIMP nsComponentManagerImpl::GetComponentESModules( nsIUTF8StringEnumerator** aESModules) { diff --git a/xpcom/components/nsIComponentManager.idl b/xpcom/components/nsIComponentManager.idl index 6b921be00401..ed02b64d301a 100644 --- a/xpcom/components/nsIComponentManager.idl +++ b/xpcom/components/nsIComponentManager.idl @@ -96,14 +96,6 @@ interface nsIComponentManager : nsISupports */ nsIArray getManifestLocations(); - /** - * Returns a list of JSM URLs which are used to create components. This - * should only be used in automation. - * - * TODO: Remove this once m-c and c-c migrations finish (bug 1881887). - */ - nsIUTF8StringEnumerator getComponentJSMs(); - /** * Returns a list of ESM URLs which are used to create components. This * should only be used in automation.