mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1883869 - Make ContentProcessMessageManager::LoadScript become fallible r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D204612
This commit is contained in:
parent
8fd100bae7
commit
917bc67aab
@ -104,6 +104,7 @@ JSObject* ContentProcessMessageManager::GetOrCreateWrapper() {
|
||||
jsapi.Init();
|
||||
|
||||
if (!GetOrCreateDOMReflectorNoWrap(jsapi.cx(), this, &val)) {
|
||||
JS_ClearPendingException(jsapi.cx());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -111,11 +112,15 @@ JSObject* ContentProcessMessageManager::GetOrCreateWrapper() {
|
||||
return &val.toObject();
|
||||
}
|
||||
|
||||
void ContentProcessMessageManager::LoadScript(const nsAString& aURL) {
|
||||
bool ContentProcessMessageManager::LoadScript(const nsAString& aURL) {
|
||||
Init();
|
||||
JS::Rooted<JSObject*> messageManager(mozilla::dom::RootingCx(),
|
||||
GetOrCreateWrapper());
|
||||
LoadScriptInternal(messageManager, aURL, true);
|
||||
JSObject* wrapper = GetOrCreateWrapper();
|
||||
if (wrapper) {
|
||||
JS::Rooted<JSObject*> messageManager(mozilla::dom::RootingCx(), wrapper);
|
||||
LoadScriptInternal(messageManager, aURL, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ContentProcessMessageManager::SetInitialProcessData(
|
||||
|
@ -58,7 +58,7 @@ class ContentProcessMessageManager : public nsIMessageSender,
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
JSObject* GetOrCreateWrapper();
|
||||
[[nodiscard]] JSObject* GetOrCreateWrapper();
|
||||
|
||||
using MessageManagerGlobal::AddMessageListener;
|
||||
using MessageManagerGlobal::AddWeakMessageListener;
|
||||
@ -84,7 +84,7 @@ class ContentProcessMessageManager : public nsIMessageSender,
|
||||
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
|
||||
}
|
||||
|
||||
virtual void LoadScript(const nsAString& aURL);
|
||||
[[nodiscard]] virtual bool LoadScript(const nsAString& aURL);
|
||||
|
||||
bool IsProcessScoped() const override { return true; }
|
||||
|
||||
|
@ -1428,8 +1428,7 @@ class SameParentProcessMessageManagerCallback : public MessageManagerCallback {
|
||||
bool aRunInGlobalScope) override {
|
||||
auto* global = ContentProcessMessageManager::Get();
|
||||
MOZ_ASSERT(!aRunInGlobalScope);
|
||||
global->LoadScript(aURL);
|
||||
return true;
|
||||
return global && global->LoadScript(aURL);
|
||||
}
|
||||
|
||||
nsresult DoSendAsyncMessage(const nsAString& aMessage,
|
||||
|
@ -2310,8 +2310,10 @@ mozilla::ipc::IPCResult ContentChild::RecvThemeChanged(
|
||||
mozilla::ipc::IPCResult ContentChild::RecvLoadProcessScript(
|
||||
const nsString& aURL) {
|
||||
auto* global = ContentProcessMessageManager::Get();
|
||||
global->LoadScript(aURL);
|
||||
return IPC_OK();
|
||||
if (global && global->LoadScript(aURL)) {
|
||||
return IPC_OK();
|
||||
}
|
||||
return IPC_FAIL(this, "ContentProcessMessageManager::LoadScript failed");
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvAsyncMessage(
|
||||
|
Loading…
Reference in New Issue
Block a user