mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1359017 - onmessageerror for MessagePort in case StructuredClone algorithm fails when deserializing, r=masayuki, r=smaug
This commit is contained in:
parent
2e66e542ea
commit
ab8673f32d
@ -920,6 +920,7 @@ GK_ATOM(onloadingerror, "onloadingerror")
|
||||
GK_ATOM(onpopstate, "onpopstate")
|
||||
GK_ATOM(only, "only") // this one is not an event
|
||||
GK_ATOM(onmessage, "onmessage")
|
||||
GK_ATOM(onmessageerror, "onmessageerror")
|
||||
GK_ATOM(onmousedown, "onmousedown")
|
||||
GK_ATOM(onmouseenter, "onmouseenter")
|
||||
GK_ATOM(onmouseleave, "onmouseleave")
|
||||
|
@ -137,6 +137,7 @@ private:
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
mPort->DispatchError();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
@ -148,6 +149,7 @@ private:
|
||||
|
||||
Sequence<OwningNonNull<MessagePort>> ports;
|
||||
if (!mData->TakeTransferredPortsAsSequence(ports)) {
|
||||
mPort->DispatchError();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -694,7 +696,7 @@ MessagePort::Entangled(nsTArray<ClonedMessageData>& aMessages)
|
||||
FallibleTArray<RefPtr<SharedMessagePortMessage>> data;
|
||||
if (NS_WARN_IF(!SharedMessagePortMessage::FromMessagesToSharedChild(aMessages,
|
||||
data))) {
|
||||
// OOM, we cannot continue.
|
||||
DispatchError();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -748,7 +750,7 @@ MessagePort::MessagesReceived(nsTArray<ClonedMessageData>& aMessages)
|
||||
FallibleTArray<RefPtr<SharedMessagePortMessage>> data;
|
||||
if (NS_WARN_IF(!SharedMessagePortMessage::FromMessagesToSharedChild(aMessages,
|
||||
data))) {
|
||||
// OOM, We cannot continue.
|
||||
DispatchError();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1004,5 +1006,28 @@ MessagePort::ForceClose(const MessagePortIdentifier& aIdentifier)
|
||||
ForceCloseHelper::ForceClose(aIdentifier);
|
||||
}
|
||||
|
||||
void
|
||||
MessagePort::DispatchError()
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> globalObject = GetParentObject();
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
if (!globalObject || !jsapi.Init(globalObject)) {
|
||||
NS_WARNING("Failed to initialize AutoJSAPI object.");
|
||||
return;
|
||||
}
|
||||
|
||||
RootedDictionary<MessageEventInit> init(jsapi.cx());
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
|
||||
RefPtr<Event> event =
|
||||
MessageEvent::Constructor(this, NS_LITERAL_STRING("messageerror"), init);
|
||||
event->SetTrusted(true);
|
||||
|
||||
bool dummy;
|
||||
DispatchEvent(event, &dummy);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -74,6 +74,8 @@ public:
|
||||
|
||||
void SetOnmessage(EventHandlerNonNull* aCallback);
|
||||
|
||||
IMPL_EVENT_HANDLER(messageerror)
|
||||
|
||||
// Non WebIDL methods
|
||||
|
||||
void UnshippedEntangle(MessagePort* aEntangledPort);
|
||||
@ -147,6 +149,8 @@ private:
|
||||
// Dispatch events from the Message Queue using a nsRunnable.
|
||||
void Dispatch();
|
||||
|
||||
void DispatchError();
|
||||
|
||||
void StartDisentangling();
|
||||
void Disentangle();
|
||||
|
||||
|
@ -17,5 +17,6 @@ interface MessagePort : EventTarget {
|
||||
|
||||
// event handlers
|
||||
attribute EventHandler onmessage;
|
||||
attribute EventHandler onmessageerror;
|
||||
};
|
||||
// MessagePort implements Transferable;
|
||||
|
Loading…
Reference in New Issue
Block a user