Bug 1359017 - onmessageerror for BroadcastChannel in case StructuredClone algorithm fails when deserializing, r=masayuki, r=smaug

This commit is contained in:
Andrea Marchesini 2017-09-12 11:57:26 +02:00
Родитель df522b457d
Коммит 1f151318f4
4 изменённых файлов: 24 добавлений и 4 удалений

Просмотреть файл

@ -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;
};