Bug 1359017 - onmessageerror for BroadcastChannel in case StructuredClone algorithm fails when deserializing, r=masayuki, r=smaug
☠☠ backed out by be8ab911f1ed ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 12 Sep 2017 11:57:26 +0200
changeset 429771 8936320bf3557898f109f2d18641e224c6628d5c
parent 429770 78cd991b074fff879264429397f6cb01d7ce8522
child 429772 65146cc073d492b94432e9ea1fd4b89e35bbf484
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki, smaug
bugs1359017
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1359017 - onmessageerror for BroadcastChannel in case StructuredClone algorithm fails when deserializing, r=masayuki, r=smaug
dom/broadcastchannel/BroadcastChannel.h
dom/broadcastchannel/BroadcastChannelChild.cpp
dom/broadcastchannel/BroadcastChannelChild.h
dom/webidl/BroadcastChannel.webidl
--- a/dom/broadcastchannel/BroadcastChannel.h
+++ b/dom/broadcastchannel/BroadcastChannel.h
@@ -63,16 +63,17 @@ public:
   }
 
   void PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
                    ErrorResult& aRv);
 
   void Close();
 
   IMPL_EVENT_HANDLER(message)
+  IMPL_EVENT_HANDLER(messageerror)
 
   void Shutdown();
 
 private:
   BroadcastChannel(nsPIDOMWindowInner* aWindow,
                    const PrincipalInfo& aPrincipalInfo,
                    const nsACString& aOrigin,
                    const nsAString& aChannel);
--- a/dom/broadcastchannel/BroadcastChannelChild.cpp
+++ b/dom/broadcastchannel/BroadcastChannelChild.cpp
@@ -75,20 +75,20 @@ BroadcastChannelChild::RecvNotify(const 
   if (!globalObject || !jsapi.Init(globalObject)) {
     NS_WARNING("Failed to initialize AutoJSAPI object.");
     return IPC_OK();
   }
 
   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();
     }
   }
 
   RootedDictionary<MessageEventInit> init(cx);
   init.mBubbles = false;
   init.mCancelable = false;
   init.mOrigin = mOrigin;
@@ -106,10 +106,26 @@ BroadcastChannelChild::RecvNotify(const 
 }
 
 void
 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
--- a/dom/broadcastchannel/BroadcastChannelChild.h
+++ b/dom/broadcastchannel/BroadcastChannelChild.h
@@ -39,16 +39,18 @@ public:
   }
 
 private:
   explicit BroadcastChannelChild(const nsACString& aOrigin);
   ~BroadcastChannelChild();
 
   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;
 
   nsString mOrigin;
 
   bool mActorDestroyed;
 };
--- a/dom/webidl/BroadcastChannel.webidl
+++ b/dom/webidl/BroadcastChannel.webidl
@@ -1,21 +1,22 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * 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),
  Exposed=(Window,Worker)]
 interface BroadcastChannel : EventTarget {
   readonly attribute DOMString name;
 
   [Throws]
   void postMessage(any message);
 
   void close();
 
-           attribute EventHandler onmessage;
+  attribute EventHandler onmessage;
+  attribute EventHandler onmessageerror;
 };