Bug 1359017 - onmessageerror for BroadcastChannel in case StructuredClone algorithm fails when deserializing, r=masayuki, r=smaug
☠☠ backed out by 18167b57d076 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 13 Sep 2017 05:59:06 +0200
changeset 380648 354139a05e750c3f74e0efbdab34436a73c962a6
parent 380647 a8d6f6fd7bda07666155c8c9288c6d6bbf417fcf
child 380649 9248962260f96b0f3d413f866aa9297989abf2d1
push id32492
push userarchaeopteryx@coole-files.de
push dateWed, 13 Sep 2017 21:59:20 +0000
treeherdermozilla-central@8645a74bbbd0 [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(cx);
       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(JSContext* aCx)
+{
+  RootedDictionary<MessageEventInit> init(aCx);
+  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(JSContext* aCx);
+
   // 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;
 };