Backed out 2 changesets (bug 1310967) for failures in messageEvent tests a=backou
authorWes Kocher <wkocher@mozilla.com>
Tue, 18 Oct 2016 10:53:44 -0700
changeset 318517 86858f4eb39603554e24cad5e35ebf6953206b9d
parent 318516 e3b464e34825445fa85040206d9b806f60647afd
child 318518 3687c50bc52e32be5da2ff335016afdb5d80c638
push id30843
push usercbook@mozilla.com
push dateWed, 19 Oct 2016 15:02:57 +0000
treeherdermozilla-central@f40960c63bfa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackou
bugs1310967
milestone52.0a1
backs outdac69b2b8d26fff4e56703c494889e64b464b088
133feae493304107a70519eb061da16c4eaf3334
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
Backed out 2 changesets (bug 1310967) for failures in messageEvent tests a=backou Backed out changeset dac69b2b8d26 (bug 1310967) Backed out changeset 133feae49330 (bug 1310967)
dom/base/EventSource.cpp
dom/base/PostMessageEvent.cpp
dom/base/WebSocket.cpp
dom/base/nsDOMDataChannel.cpp
dom/broadcastchannel/BroadcastChannelChild.cpp
dom/events/MessageEvent.cpp
dom/events/MessageEvent.h
dom/events/test/test_messageEvent.html
dom/messagechannel/MessagePort.cpp
dom/presentation/PresentationConnection.cpp
dom/webidl/MessageEvent.webidl
dom/workers/WorkerPrivate.cpp
--- a/dom/base/EventSource.cpp
+++ b/dom/base/EventSource.cpp
@@ -1076,18 +1076,17 @@ EventSource::DispatchAllMessageEvents()
     }
 
     // create an event that uses the MessageEvent interface,
     // which does not bubble, is not cancelable, and has no default action
 
     RefPtr<MessageEvent> event = new MessageEvent(this, nullptr, nullptr);
 
     event->InitMessageEvent(nullptr, message->mEventName, false, false, jsData,
-                            mOrigin, message->mLastEventID, nullptr,
-                            Sequence<OwningNonNull<MessagePort>>());
+                            mOrigin, message->mLastEventID, nullptr, nullptr);
     event->SetTrusted(true);
 
     rv = DispatchDOMEvent(nullptr, static_cast<Event*>(event), nullptr,
                           nullptr);
     if (NS_FAILED(rv)) {
       NS_WARNING("Failed to dispatch the message event!!!");
       return;
     }
--- a/dom/base/PostMessageEvent.cpp
+++ b/dom/base/PostMessageEvent.cpp
@@ -142,18 +142,17 @@ PostMessageEvent::Run()
 
 
   Nullable<WindowProxyOrMessagePort> source;
   source.SetValue().SetAsWindowProxy() = mSource ? mSource->AsOuter() : nullptr;
 
   event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"),
                           false /*non-bubbling */, false /*cancelable */,
                           messageData, mCallerOrigin,
-                          EmptyString(), source,
-                          Sequence<OwningNonNull<MessagePort>>());
+                          EmptyString(), source, nullptr);
 
   nsTArray<RefPtr<MessagePort>> ports = TakeTransferredPorts();
   event->SetPorts(Move(ports));
 
   // We can't simply call dispatchEvent on the window because doing so ends
   // up flipping the trusted bit on the event, and we don't want that to
   // happen because then untrusted content can call postMessage on a chrome
   // window if it can get a reference to it.
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -2004,17 +2004,17 @@ WebSocket::CreateAndDispatchMessageEvent
 
   // create an event that uses the MessageEvent interface,
   // which does not bubble, is not cancelable, and has no default action
 
   RefPtr<MessageEvent> event = new MessageEvent(this, nullptr, nullptr);
 
   event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"), false, false,
                           jsData, mImpl->mUTF16Origin, EmptyString(), nullptr,
-                          Sequence<OwningNonNull<MessagePort>>());
+                          nullptr);
   event->SetTrusted(true);
 
   return DispatchDOMEvent(nullptr, static_cast<Event*>(event), nullptr,
                           nullptr);
 }
 
 nsresult
 WebSocket::CreateAndDispatchCloseEvent(bool aWasClean,
--- a/dom/base/nsDOMDataChannel.cpp
+++ b/dom/base/nsDOMDataChannel.cpp
@@ -400,18 +400,17 @@ nsDOMDataChannel::DoOnMessageAvailable(c
     NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
 
     jsData.setString(jsString);
   }
 
   RefPtr<MessageEvent> event = new MessageEvent(this, nullptr, nullptr);
 
   event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"), false, false,
-                          jsData, mOrigin, EmptyString(), nullptr,
-                          Sequence<OwningNonNull<MessagePort>>());
+                          jsData, mOrigin, EmptyString(), nullptr, nullptr);
   event->SetTrusted(true);
 
   LOG(("%p(%p): %s - Dispatching\n",this,(void*)mDataChannel,__FUNCTION__));
   rv = DispatchDOMEvent(nullptr, static_cast<Event*>(event), nullptr, nullptr);
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch the message event!!!");
   }
   return rv;
--- a/dom/broadcastchannel/BroadcastChannelChild.cpp
+++ b/dom/broadcastchannel/BroadcastChannelChild.cpp
@@ -101,17 +101,17 @@ BroadcastChannelChild::RecvNotify(const 
       rv.SuppressException();
       return true;
     }
   }
 
   RootedDictionary<MessageEventInit> init(cx);
   init.mBubbles = false;
   init.mCancelable = false;
-  init.mOrigin = mOrigin;
+  init.mOrigin.Construct(mOrigin);
   init.mData = value;
 
   ErrorResult rv;
   RefPtr<MessageEvent> event =
     MessageEvent::Constructor(mBC, NS_LITERAL_STRING("message"), init, rv);
   if (NS_WARN_IF(rv.Failed())) {
     rv.SuppressException();
     return true;
--- a/dom/events/MessageEvent.cpp
+++ b/dom/events/MessageEvent.cpp
@@ -41,16 +41,17 @@ NS_INTERFACE_MAP_END_INHERITING(Event)
 NS_IMPL_ADDREF_INHERITED(MessageEvent, Event)
 NS_IMPL_RELEASE_INHERITED(MessageEvent, Event)
 
 MessageEvent::MessageEvent(EventTarget* aOwner,
                            nsPresContext* aPresContext,
                            WidgetEvent* aEvent)
   : Event(aOwner, aPresContext, aEvent)
   , mData(JS::UndefinedValue())
+  , mPortsSet(false)
 {
 }
 
 MessageEvent::~MessageEvent()
 {
   mData.setUndefined();
   DropJSObjects(this);
 }
@@ -114,42 +115,50 @@ MessageEvent::Constructor(EventTarget* a
   event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
   bool trusted = event->Init(aEventTarget);
   event->SetTrusted(trusted);
 
   event->mData = aParam.mData;
 
   mozilla::HoldJSObjects(event.get());
 
-  event->mOrigin = aParam.mOrigin;
-  event->mLastEventId = aParam.mLastEventId;
+  if (aParam.mOrigin.WasPassed()) {
+    event->mOrigin = aParam.mOrigin.Value();
+  }
+
+  if (aParam.mLastEventId.WasPassed()) {
+    event->mLastEventId = aParam.mLastEventId.Value();
+  }
 
   if (!aParam.mSource.IsNull()) {
     if (aParam.mSource.Value().IsWindow()) {
       event->mWindowSource = aParam.mSource.Value().GetAsWindow()->AsInner();
     } else {
       event->mPortSource = aParam.mSource.Value().GetAsMessagePort();
     }
 
     MOZ_ASSERT(event->mWindowSource || event->mPortSource);
   }
 
-  event->mPorts.AppendElements(aParam.mPorts);
+  if (aParam.mPorts.WasPassed() && !aParam.mPorts.Value().IsNull()) {
+    event->mPorts.AppendElements(aParam.mPorts.Value().Value());
+    event->mPortsSet = true;
+  }
 
   return event.forget();
 }
 
 void
 MessageEvent::InitMessageEvent(JSContext* aCx, const nsAString& aType,
                                bool aCanBubble, bool aCancelable,
                                JS::Handle<JS::Value> aData,
                                const nsAString& aOrigin,
                                const nsAString& aLastEventId,
                                const Nullable<WindowProxyOrMessagePort>& aSource,
-                               const Sequence<OwningNonNull<MessagePort>>& aPorts)
+                               const Nullable<Sequence<OwningNonNull<MessagePort>>>& aPorts)
 {
   Event::InitEvent(aType, aCanBubble, aCancelable);
   mData = aData;
   mozilla::HoldJSObjects(this);
   mOrigin = aOrigin;
   mLastEventId = aLastEventId;
 
   mWindowSource = nullptr;
@@ -160,31 +169,43 @@ MessageEvent::InitMessageEvent(JSContext
       auto* windowProxy = aSource.Value().GetAsWindowProxy();
       mWindowSource = windowProxy ? windowProxy->GetCurrentInnerWindow() : nullptr;
     } else {
       mPortSource = &aSource.Value().GetAsMessagePort();
     }
   }
 
   mPorts.Clear();
-  mPorts.AppendElements(aPorts);
+  mPortsSet = false;
+
+  if (!aPorts.IsNull()) {
+    mPorts.AppendElements(aPorts.Value());
+    mPortsSet = true;
+  }
+
   MessageEventBinding::ClearCachedPortsValue(this);
 }
 
 void
-MessageEvent::GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts)
+MessageEvent::GetPorts(Nullable<nsTArray<RefPtr<MessagePort>>>& aPorts)
 {
-  aPorts = mPorts;
+  if (!mPortsSet) {
+    aPorts.SetNull();
+    return;
+  }
+
+  aPorts.SetValue(mPorts);
 }
 
 void
 MessageEvent::SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts)
 {
-  MOZ_ASSERT(mPorts.IsEmpty());
+  MOZ_ASSERT(mPorts.IsEmpty() && !mPortsSet);
   mPorts = Move(aPorts);
+  mPortsSet = true;
 }
 
 void
 MessageEvent::SetSource(mozilla::dom::MessagePort* aPort)
 {
   mPortSource = aPort;
 }
 
--- a/dom/events/MessageEvent.h
+++ b/dom/events/MessageEvent.h
@@ -42,17 +42,17 @@ public:
   virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData,
                ErrorResult& aRv);
   void GetOrigin(nsAString&) const;
   void GetLastEventId(nsAString&) const;
   void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const;
 
-  void GetPorts(nsTArray<RefPtr<MessagePort>>& aPorts);
+  void GetPorts(Nullable<nsTArray<RefPtr<MessagePort>>>& aPorts);
 
   void SetPorts(nsTArray<RefPtr<MessagePort>>&& aPorts);
 
   // Non WebIDL methods
   void SetSource(mozilla::dom::MessagePort* aPort);
 
   void SetSource(nsPIDOMWindowInner* aWindow)
   {
@@ -70,27 +70,28 @@ public:
               const nsAString& aType,
               const MessageEventInit& aEventInit,
               ErrorResult& aRv);
 
   void InitMessageEvent(JSContext* aCx, const nsAString& aType, bool aCanBubble,
                         bool aCancelable, JS::Handle<JS::Value> aData,
                         const nsAString& aOrigin, const nsAString& aLastEventId,
                         const Nullable<WindowProxyOrMessagePort>& aSource,
-                        const Sequence<OwningNonNull<MessagePort>>& aPorts);
+                        const Nullable<Sequence<OwningNonNull<MessagePort>>>& aPorts);
 
 protected:
   ~MessageEvent();
 
 private:
   JS::Heap<JS::Value> mData;
   nsString mOrigin;
   nsString mLastEventId;
   RefPtr<nsPIDOMWindowInner> mWindowSource;
   RefPtr<MessagePort> mPortSource;
 
   nsTArray<RefPtr<MessagePort>> mPorts;
+  bool mPortsSet;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_MessageEvent_h_
--- a/dom/events/test/test_messageEvent.html
+++ b/dom/events/test/test_messageEvent.html
@@ -12,17 +12,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
   <script type="application/javascript">
   function testMessageEvent(e, test) {
     ok(e, "MessageEvent created");
     is(e.type, 'message', 'MessageEvent.type is right');
 
-    is(e.data, 'data' in test ? test.data : null, 'MessageEvent.data is ok');
+    is(e.data, 'data' in test ? test.data : undefined, 'MessageEvent.data is ok');
     is(e.origin, 'origin' in test ? test.origin : '', 'MessageEvent.origin is ok');
     is(e.lastEventId, 'lastEventId' in test ? test.lastEventId : '', 'MessageEvent.lastEventId is ok');
     is(e.source, 'source' in test ? test.source : null, 'MessageEvent.source is ok');
 
     if (test.ports != undefined) {
       is(e.ports.length, test.ports.length, 'MessageEvent.ports is ok');
       is(e.ports, e.ports, 'MessageEvent.ports is ok');
     } else {
@@ -38,32 +38,32 @@ https://bugzilla.mozilla.org/show_bug.cg
       { data: 42 },
       { data: {} },
       { data: true, origin: 'wow' },
       { data: [], lastEventId: 'wow2'  },
       { data: null, source: null },
       { data: window, source: window },
       { data: window, source: channel.port1 },
       { data: window, source: channel.port1, ports: [ channel.port1, channel.port2 ] },
-      { data: null, ports: [] },
+      { data: null, ports: null },
     ];
 
     while (tests.length) {
       var test = tests.shift();
 
       var e = new MessageEvent('message', test);
       testMessageEvent(e, test);
 
       e = new MessageEvent('message');
       e.initMessageEvent('message', true, true,
-                         'data' in test ? test.data : null,
+                         'data' in test ? test.data : undefined,
                          'origin' in test ? test.origin : '',
                          'lastEventId' in test ? test.lastEventId : '',
                          'source' in test ? test.source : null,
-                         'ports' in test ? test.ports : []);
+                         'ports' in test ? test.ports : null);
       testMessageEvent(e, test);
     }
 
     try {
       var e = new MessageEvent('foobar', { source: 42 });
       ok(false, "Source has to be a window or a port");
     } catch(e) {
       ok(true, "Source has to be a window or a port");
--- a/dom/messagechannel/MessagePort.cpp
+++ b/dom/messagechannel/MessagePort.cpp
@@ -132,18 +132,17 @@ private:
     nsCOMPtr<mozilla::dom::EventTarget> eventTarget =
       do_QueryInterface(mPort->GetOwner());
     RefPtr<MessageEvent> event =
       new MessageEvent(eventTarget, nullptr, nullptr);
 
     event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"),
                             false /* non-bubbling */,
                             false /* cancelable */, value, EmptyString(),
-                            EmptyString(), nullptr,
-                            Sequence<OwningNonNull<MessagePort>>());
+                            EmptyString(), nullptr, nullptr);
     event->SetTrusted(true);
     event->SetSource(mPort);
 
     nsTArray<RefPtr<MessagePort>> ports = mData->TakeTransferredPorts();
     event->SetPorts(Move(ports));
 
     bool dummy;
     mPort->DispatchEvent(static_cast<dom::Event*>(event.get()), &dummy);
--- a/dom/presentation/PresentationConnection.cpp
+++ b/dom/presentation/PresentationConnection.cpp
@@ -575,18 +575,17 @@ PresentationConnection::DispatchMessageE
     return rv;
   }
 
   RefPtr<MessageEvent> messageEvent = new MessageEvent(this, nullptr, nullptr);
 
   messageEvent->InitMessageEvent(nullptr,
                                  NS_LITERAL_STRING("message"),
                                  false, false, aData, origin,
-                                 EmptyString(), nullptr,
-                                 Sequence<OwningNonNull<MessagePort>>());
+                                 EmptyString(), nullptr, nullptr);
   messageEvent->SetTrusted(true);
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(this, static_cast<Event*>(messageEvent));
   return asyncDispatcher->PostDOMEvent();
 }
 
 nsresult
--- a/dom/webidl/MessageEvent.webidl
+++ b/dom/webidl/MessageEvent.webidl
@@ -36,23 +36,23 @@ interface MessageEvent : Event {
   readonly attribute (WindowProxy or MessagePort)? source;
 
   /**
    * Initializes this event with the given data, in a manner analogous to
    * the similarly-named method on the nsIDOMEvent interface, also setting the
    * data, origin, source, and lastEventId attributes of this appropriately.
    */
   [Pure, Cached, Frozen]
-  readonly attribute sequence<MessagePort> ports;
+  readonly attribute sequence<MessagePort>? ports;
 
   void initMessageEvent(DOMString type, boolean bubbles, boolean cancelable,
                         any data, DOMString origin, DOMString lastEventId,
                         (WindowProxy or MessagePort)? source,
-                        sequence<MessagePort> ports);
+                        sequence<MessagePort>? ports);
 };
 
 dictionary MessageEventInit : EventInit {
-  any data = null;
-  DOMString origin = "";
-  DOMString lastEventId = "";
+  any data;
+  DOMString origin;
+  DOMString lastEventId;
   (Window or MessagePort)? source = null;
-  sequence<MessagePort> ports = [];
+  sequence<MessagePort>? ports;
 };
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -718,17 +718,17 @@ public:
       event->InitMessageEvent(nullptr,
                               NS_LITERAL_STRING("message"),
                               false /* non-bubbling */,
                               false /* cancelable */,
                               messageData,
                               EmptyString(),
                               EmptyString(),
                               nullptr,
-                              Sequence<OwningNonNull<MessagePort>>());
+                              nullptr);
       event->SetPorts(Move(ports));
       domEvent = do_QueryObject(event);
     }
 
     domEvent->SetTrusted(true);
 
     nsEventStatus dummy = nsEventStatus_eIgnore;
     aTarget->DispatchDOMEvent(nullptr, domEvent, nullptr, &dummy);
@@ -810,17 +810,17 @@ private:
     event->InitMessageEvent(nullptr,
                             NS_LITERAL_STRING("message"),
                             false, // canBubble
                             true, // cancelable
                             data,
                             EmptyString(),
                             EmptyString(),
                             nullptr,
-                            Sequence<OwningNonNull<MessagePort>>());
+                            nullptr);
     event->SetTrusted(true);
 
     nsCOMPtr<nsIDOMEvent> domEvent = do_QueryObject(event);
     nsEventStatus status = nsEventStatus_eIgnore;
     globalScope->DispatchDOMEvent(nullptr, domEvent, nullptr, &status);
     return true;
   }
 };