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:
@@ -67,27 +67,11 @@ dictionary ProcessActorOptions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
dictionary ProcessActorSidedOptions {
|
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.
|
* The ESM path which should be loaded for the actor on this side.
|
||||||
*
|
*
|
||||||
* Mutually exclusive with `moduleURI`.
|
* If this is not passed, the specified side cannot receive messages, but may
|
||||||
*
|
* send them using `sendAsyncMessage` or `sendQuery`.
|
||||||
* If neither this nor `moduleURI` is passed, the specified side cannot
|
|
||||||
* receive messages, but may send them using `sendAsyncMessage` or
|
|
||||||
* `sendQuery`.
|
|
||||||
*/
|
*/
|
||||||
ByteString esModuleURI;
|
ByteString esModuleURI;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -125,27 +125,11 @@ dictionary WindowActorOptions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
dictionary WindowActorSidedOptions {
|
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.
|
* The ESM path which should be loaded for the actor on this side.
|
||||||
*
|
*
|
||||||
* Mutually exclusive with `moduleURI`.
|
* If this is not is passed, the specified side cannot receive messages, but
|
||||||
*
|
* may send them using `sendAsyncMessage` or `sendQuery`.
|
||||||
* If neither this nor `moduleURI` is passed, the specified side cannot
|
|
||||||
* receive messages, but may send them using `sendAsyncMessage` or
|
|
||||||
* `sendQuery`.
|
|
||||||
*/
|
*/
|
||||||
ByteString esModuleURI;
|
ByteString esModuleURI;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -307,10 +307,6 @@ struct JSWindowActorInfo
|
|||||||
nsCString name;
|
nsCString name;
|
||||||
bool allFrames;
|
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 is to align with JSProcessActorInfo.
|
||||||
// This attribute isn't used for JSWindow Actors.
|
// This attribute isn't used for JSWindow Actors.
|
||||||
bool loadInDevToolsLoader;
|
bool loadInDevToolsLoader;
|
||||||
|
|||||||
@@ -75,21 +75,11 @@ already_AddRefed<JSActor> JSActorManager::GetActor(JSContext* aCx,
|
|||||||
|
|
||||||
// If a module URI was provided, use it to construct an instance of the actor.
|
// If a module URI was provided, use it to construct an instance of the actor.
|
||||||
JS::Rooted<JSObject*> actorObj(aCx);
|
JS::Rooted<JSObject*> actorObj(aCx);
|
||||||
if (side.mModuleURI || side.mESModuleURI) {
|
if (side.mESModuleURI) {
|
||||||
JS::Rooted<JSObject*> exports(aCx);
|
JS::Rooted<JSObject*> exports(aCx);
|
||||||
if (side.mModuleURI) {
|
aRv = loader->ImportESModule(aCx, side.mESModuleURI.ref(), &exports);
|
||||||
// TODO: Remove this once m-c, c-c, and out-of-tree code migrations finish
|
if (aRv.Failed()) {
|
||||||
// (bug 1866732).
|
return nullptr;
|
||||||
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!");
|
MOZ_ASSERT(exports, "null exports!");
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,7 @@ class JSActorProtocolUtils {
|
|||||||
static void FromIPCShared(ProtoT& aProto, const ActorInfoT& aInfo) {
|
static void FromIPCShared(ProtoT& aProto, const ActorInfoT& aInfo) {
|
||||||
aProto->mRemoteTypes = aInfo.remoteTypes().Clone();
|
aProto->mRemoteTypes = aInfo.remoteTypes().Clone();
|
||||||
|
|
||||||
if (aInfo.isESModule()) {
|
aProto->mChild.mESModuleURI = aInfo.url();
|
||||||
aProto->mChild.mESModuleURI = aInfo.url();
|
|
||||||
} else {
|
|
||||||
aProto->mChild.mModuleURI = aInfo.url();
|
|
||||||
}
|
|
||||||
|
|
||||||
aProto->mLoadInDevToolsLoader = aInfo.loadInDevToolsLoader();
|
aProto->mLoadInDevToolsLoader = aInfo.loadInDevToolsLoader();
|
||||||
|
|
||||||
@@ -37,13 +33,7 @@ class JSActorProtocolUtils {
|
|||||||
|
|
||||||
aInfo.remoteTypes() = aProto->mRemoteTypes.Clone();
|
aInfo.remoteTypes() = aProto->mRemoteTypes.Clone();
|
||||||
|
|
||||||
if (aProto->mChild.mModuleURI) {
|
aInfo.url() = aProto->mChild.mESModuleURI;
|
||||||
aInfo.url() = aProto->mChild.mModuleURI;
|
|
||||||
aInfo.isESModule() = false;
|
|
||||||
} else {
|
|
||||||
aInfo.url() = aProto->mChild.mESModuleURI;
|
|
||||||
aInfo.isESModule() = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
aInfo.loadInDevToolsLoader() = aProto->mLoadInDevToolsLoader;
|
aInfo.loadInDevToolsLoader() = aProto->mLoadInDevToolsLoader;
|
||||||
|
|
||||||
@@ -62,15 +52,7 @@ class JSActorProtocolUtils {
|
|||||||
if (aOptions.mParent.WasPassed()) {
|
if (aOptions.mParent.WasPassed()) {
|
||||||
const auto& parentOptions = aOptions.mParent.Value();
|
const auto& parentOptions = aOptions.mParent.Value();
|
||||||
|
|
||||||
if (parentOptions.mModuleURI.WasPassed()) {
|
if (parentOptions.mEsModuleURI.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(
|
aProto->mParent.mESModuleURI.emplace(
|
||||||
parentOptions.mEsModuleURI.Value());
|
parentOptions.mEsModuleURI.Value());
|
||||||
} else {
|
} else {
|
||||||
@@ -82,15 +64,7 @@ class JSActorProtocolUtils {
|
|||||||
if (aOptions.mChild.WasPassed()) {
|
if (aOptions.mChild.WasPassed()) {
|
||||||
const auto& childOptions = aOptions.mChild.Value();
|
const auto& childOptions = aOptions.mChild.Value();
|
||||||
|
|
||||||
if (childOptions.mModuleURI.WasPassed()) {
|
if (childOptions.mEsModuleURI.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());
|
aProto->mChild.mESModuleURI.emplace(childOptions.mEsModuleURI.Value());
|
||||||
} else {
|
} else {
|
||||||
aRv.ThrowNotSupportedError(
|
aRv.ThrowNotSupportedError(
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ class JSActorService final {
|
|||||||
class JSActorProtocol : public nsISupports {
|
class JSActorProtocol : public nsISupports {
|
||||||
public:
|
public:
|
||||||
struct Sided {
|
struct Sided {
|
||||||
Maybe<nsCString> mModuleURI;
|
|
||||||
Maybe<nsCString> mESModuleURI;
|
Maybe<nsCString> mESModuleURI;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user