Bug 1866732 - Part 2: Remove support for loading JSMs in Actors. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D233363
This commit is contained in:
Tooru Fujisawa
2025-01-21 13:37:18 +00:00
parent 12c1ff39be
commit db5545fbaf
6 changed files with 12 additions and 85 deletions

View File

@@ -67,27 +67,11 @@ 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`.
*
* TODO: Remove this once m-c, c-c, and out-of-tree code migrations finish
* (bug 1866732).
*/
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`.
* If this is not passed, the specified side cannot receive messages, but may
* send them using `sendAsyncMessage` or `sendQuery`.
*/
ByteString esModuleURI;
};

View File

@@ -125,27 +125,11 @@ 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`.
*
* TODO: Remove this once m-c, c-c, and out-of-tree code migrations finish
* (bug 1866732).
*/
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`.
* If this is not is passed, the specified side cannot receive messages, but
* may send them using `sendAsyncMessage` or `sendQuery`.
*/
ByteString esModuleURI;
};

View File

@@ -307,10 +307,6 @@ struct JSWindowActorInfo
nsCString name;
bool allFrames;
// True if `url` is for ESM.
// False if `url` is for JSM or nothing.
bool isESModule;
// This is to align with JSProcessActorInfo.
// This attribute isn't used for JSWindow Actors.
bool loadInDevToolsLoader;

View File

@@ -75,22 +75,12 @@ already_AddRefed<JSActor> JSActorManager::GetActor(JSContext* aCx,
// If a module URI was provided, use it to construct an instance of the actor.
JS::Rooted<JSObject*> actorObj(aCx);
if (side.mModuleURI || side.mESModuleURI) {
if (side.mESModuleURI) {
JS::Rooted<JSObject*> exports(aCx);
if (side.mModuleURI) {
// TODO: Remove this once m-c, c-c, and out-of-tree code migrations finish
// (bug 1866732).
JS::Rooted<JSObject*> 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;
}
}
MOZ_ASSERT(exports, "null exports!");
// Load the specific property from our module.

View File

@@ -20,11 +20,7 @@ class JSActorProtocolUtils {
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->mLoadInDevToolsLoader = aInfo.loadInDevToolsLoader();
@@ -37,13 +33,7 @@ class JSActorProtocolUtils {
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.loadInDevToolsLoader() = aProto->mLoadInDevToolsLoader;
@@ -62,15 +52,7 @@ class JSActorProtocolUtils {
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 {
@@ -82,15 +64,7 @@ class JSActorProtocolUtils {
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(

View File

@@ -98,7 +98,6 @@ class JSActorService final {
class JSActorProtocol : public nsISupports {
public:
struct Sided {
Maybe<nsCString> mModuleURI;
Maybe<nsCString> mESModuleURI;
};