Backed out changeset 7b45c1aebf7f (bug 1359017)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Wed, 13 Sep 2017 08:56:13 +0200
changeset 432615 14293eee37445e85557d5b2ca1763a6e36a20b34
parent 432614 a1dfff8f131db045f60c4b70642f0b537d42c77c
child 432616 37abc7027f1d66db0a2ffee7afa08b705a4bbc6b
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1359017
milestone57.0a1
backs out7b45c1aebf7ffaaedafa8cabd3f6ef2a2a1c3b94
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 changeset 7b45c1aebf7f (bug 1359017)
dom/base/PostMessageEvent.cpp
dom/base/PostMessageEvent.h
dom/events/EventNameList.h
dom/webidl/EventHandler.webidl
widget/EventMessageList.h
--- a/dom/base/PostMessageEvent.cpp
+++ b/dom/base/PostMessageEvent.cpp
@@ -138,86 +138,60 @@ PostMessageEvent::Run()
         nsContentUtils::eDOM_PROPERTIES,
         "TargetPrincipalDoesNotMatch",
         params, ArrayLength(params));
 
       return NS_OK;
     }
   }
 
-  IgnoredErrorResult rv;
+  ErrorResult rv;
   JS::Rooted<JS::Value> messageData(cx);
-  nsCOMPtr<mozilla::dom::EventTarget> eventTarget = do_QueryObject(targetWindow);
+  nsCOMPtr<nsPIDOMWindowInner> window = targetWindow->AsInner();
 
-  Read(targetWindow->AsInner(), cx, &messageData, rv);
+  Read(window, cx, &messageData, rv);
   if (NS_WARN_IF(rv.Failed())) {
-    DispatchError(cx, targetWindow, eventTarget);
-    return NS_OK;
+    return rv.StealNSResult();
   }
 
   // Create the event
-  RefPtr<MessageEvent> event = new MessageEvent(eventTarget, nullptr, nullptr);
+  nsCOMPtr<mozilla::dom::EventTarget> eventTarget = do_QueryObject(targetWindow);
+  RefPtr<MessageEvent> event =
+    new MessageEvent(eventTarget, nullptr, nullptr);
 
 
   Nullable<WindowProxyOrMessagePortOrServiceWorker> source;
   source.SetValue().SetAsWindowProxy() = mSource ? mSource->AsOuter() : nullptr;
 
   Sequence<OwningNonNull<MessagePort>> ports;
   if (!TakeTransferredPortsAsSequence(ports)) {
-    DispatchError(cx, targetWindow, eventTarget);
-    return NS_OK;
+    return NS_ERROR_OUT_OF_MEMORY;
   }
 
   event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"),
                           false /*non-bubbling */, false /*cancelable */,
                           messageData, mCallerOrigin,
                           EmptyString(), source, ports);
 
-  Dispatch(targetWindow, event);
-  return NS_OK;
-}
-
-void
-PostMessageEvent::DispatchError(JSContext* aCx, nsGlobalWindow* aTargetWindow,
-                                mozilla::dom::EventTarget* aEventTarget)
-{
-  RootedDictionary<MessageEventInit> init(aCx);
-  init.mBubbles = false;
-  init.mCancelable = false;
-  init.mOrigin = mCallerOrigin;
-
-  if (mSource) {
-    init.mSource.SetValue().SetAsWindowProxy() = mSource->AsOuter();
-  }
-
-  RefPtr<Event> event =
-    MessageEvent::Constructor(aEventTarget, NS_LITERAL_STRING("messageerror"),
-                              init);
-  Dispatch(aTargetWindow, event);
-}
-
-void
-PostMessageEvent::Dispatch(nsGlobalWindow* aTargetWindow, Event* aEvent)
-{
   // 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.
 
-  nsIPresShell *shell = aTargetWindow->GetExtantDoc()->GetShell();
+  nsIPresShell *shell = targetWindow->GetExtantDoc()->GetShell();
   RefPtr<nsPresContext> presContext;
-  if (shell) {
+  if (shell)
     presContext = shell->GetPresContext();
-  }
 
-  aEvent->SetTrusted(mTrustedCaller);
-  WidgetEvent* internalEvent = aEvent->WidgetEventPtr();
+  event->SetTrusted(mTrustedCaller);
+  WidgetEvent* internalEvent = event->WidgetEventPtr();
 
   nsEventStatus status = nsEventStatus_eIgnore;
-  EventDispatcher::Dispatch(aTargetWindow->AsInner(),
+  EventDispatcher::Dispatch(window,
                             presContext,
                             internalEvent,
-                            aEvent,
+                            static_cast<dom::Event*>(event.get()),
                             &status);
+  return NS_OK;
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/PostMessageEvent.h
+++ b/dom/base/PostMessageEvent.h
@@ -35,23 +35,16 @@ public:
                    nsGlobalWindow* aTargetWindow,
                    nsIPrincipal* aProvidedPrincipal,
                    nsIDocument* aSourceDocument,
                    bool aTrustedCaller);
 
 private:
   ~PostMessageEvent();
 
-  void
-  Dispatch(nsGlobalWindow* aTargetWindow, Event* aEvent);
-
-  void
-  DispatchError(JSContext* aCx, nsGlobalWindow* aTargetWindow,
-                mozilla::dom::EventTarget* aEventTarget);
-
   RefPtr<nsGlobalWindow> mSource;
   nsString mCallerOrigin;
   RefPtr<nsGlobalWindow> mTargetWindow;
   nsCOMPtr<nsIPrincipal> mProvidedPrincipal;
   nsCOMPtr<nsIDocument> mSourceDocument;
   bool mTrustedCaller;
 };
 
--- a/dom/events/EventNameList.h
+++ b/dom/events/EventNameList.h
@@ -546,20 +546,16 @@ WINDOW_EVENT(languagechange,
              eBasicEventClass)
 // XXXbz Should the onmessage attribute on <body> really not work?  If so, do we
 // need a different macro to flag things like that (IDL, but not content
 // attributes on body/frameset), or is just using EventNameType_None enough?
 WINDOW_EVENT(message,
              eMessage,
              EventNameType_None,
              eBasicEventClass)
-WINDOW_EVENT(messageerror,
-             eMessageError,
-             EventNameType_HTMLBodyOrFramesetOnly,
-             eBasicEventClass)
 WINDOW_EVENT(offline,
              eOffline,
              EventNameType_XUL | EventNameType_HTMLBodyOrFramesetOnly,
              eBasicEventClass)
 WINDOW_EVENT(online,
              eOnline,
              EventNameType_XUL | EventNameType_HTMLBodyOrFramesetOnly,
              eBasicEventClass)
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -142,17 +142,16 @@ interface GlobalEventHandlers {
 [NoInterfaceObject]
 interface WindowEventHandlers {
            attribute EventHandler onafterprint;
            attribute EventHandler onbeforeprint;
            attribute OnBeforeUnloadEventHandler onbeforeunload;
            attribute EventHandler onhashchange;
            attribute EventHandler onlanguagechange;
            attribute EventHandler onmessage;
-           attribute EventHandler onmessageerror;
            attribute EventHandler onoffline;
            attribute EventHandler ononline;
            attribute EventHandler onpagehide;
            attribute EventHandler onpageshow;
            attribute EventHandler onpopstate;
            attribute EventHandler onstorage;
            attribute EventHandler onunload;
 };
--- a/widget/EventMessageList.h
+++ b/widget/EventMessageList.h
@@ -369,17 +369,16 @@ NS_EVENT_MESSAGE(eAudioComplete)
 // script notification events
 NS_EVENT_MESSAGE(eBeforeScriptExecute)
 NS_EVENT_MESSAGE(eAfterScriptExecute)
 
 NS_EVENT_MESSAGE(eBeforePrint)
 NS_EVENT_MESSAGE(eAfterPrint)
 
 NS_EVENT_MESSAGE(eMessage)
-NS_EVENT_MESSAGE(eMessageError)
 
 // Menu open event
 NS_EVENT_MESSAGE(eOpen)
 
 // Device motion and orientation
 NS_EVENT_MESSAGE(eDeviceOrientation)
 NS_EVENT_MESSAGE(eAbsoluteDeviceOrientation)
 NS_EVENT_MESSAGE(eDeviceMotion)