зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1359017 - onmessageerror for BroadcastChannel in case StructuredClone algorithm fails when deserializing, r=masayuki, r=smaug
This commit is contained in:
Родитель
df522b457d
Коммит
1f151318f4
|
@ -68,6 +68,7 @@ public:
|
|||
void Close();
|
||||
|
||||
IMPL_EVENT_HANDLER(message)
|
||||
IMPL_EVENT_HANDLER(messageerror)
|
||||
|
||||
void Shutdown();
|
||||
|
||||
|
|
|
@ -80,10 +80,10 @@ BroadcastChannelChild::RecvNotify(const ClonedMessageData& aData)
|
|||
JSContext* cx = jsapi.cx();
|
||||
JS::Rooted<JS::Value> value(cx, JS::NullValue());
|
||||
if (cloneData.DataLength()) {
|
||||
ErrorResult rv;
|
||||
IgnoredErrorResult rv;
|
||||
cloneData.Read(cx, &value, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
rv.SuppressException();
|
||||
DispatchError();
|
||||
return IPC_OK();
|
||||
}
|
||||
}
|
||||
|
@ -111,5 +111,21 @@ BroadcastChannelChild::ActorDestroy(ActorDestroyReason aWhy)
|
|||
mActorDestroyed = true;
|
||||
}
|
||||
|
||||
void
|
||||
BroadcastChannelChild::DispatchError()
|
||||
{
|
||||
MessageEventInit init;
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
init.mOrigin = mOrigin;
|
||||
|
||||
RefPtr<Event> event =
|
||||
MessageEvent::Constructor(mBC, NS_LITERAL_STRING("messageerror"), init);
|
||||
event->SetTrusted(true);
|
||||
|
||||
bool dummy;
|
||||
mBC->DispatchEvent(event, &dummy);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -44,6 +44,8 @@ private:
|
|||
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
void DispatchError();
|
||||
|
||||
// This raw pointer is actually the parent object.
|
||||
// It's set to null when the parent object is deleted.
|
||||
BroadcastChannel* mBC;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* For more information on this interface, please see
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts
|
||||
* https://html.spec.whatwg.org/#broadcastchannel
|
||||
*/
|
||||
|
||||
[Constructor(DOMString channel),
|
||||
|
@ -17,5 +17,6 @@ interface BroadcastChannel : EventTarget {
|
|||
|
||||
void close();
|
||||
|
||||
attribute EventHandler onmessage;
|
||||
attribute EventHandler onmessage;
|
||||
attribute EventHandler onmessageerror;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче