Bug 1313762 - SharedWorker::PreHandleEvent must be able to deal with widget events, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 11 Nov 2016 16:23:32 +0100
changeset 352196 3f11622c5a784b8789c220e4c10345d36dfc74f4
parent 352195 3f1dcd04bc47823809e7776ca852977c3ed2881d
child 352197 733596007d62aafce8e07da062881c24c7450e5c
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1313762
milestone52.0a1
Bug 1313762 - SharedWorker::PreHandleEvent must be able to deal with widget events, r=smaug
dom/workers/SharedWorker.cpp
--- a/dom/workers/SharedWorker.cpp
+++ b/dom/workers/SharedWorker.cpp
@@ -183,19 +183,24 @@ SharedWorker::WrapObject(JSContext* aCx,
   return SharedWorkerBinding::Wrap(aCx, this, aGivenProto);
 }
 
 nsresult
 SharedWorker::PreHandleEvent(EventChainPreVisitor& aVisitor)
 {
   AssertIsOnMainThread();
 
-  nsIDOMEvent*& event = aVisitor.mDOMEvent;
+  if (IsFrozen()) {
+    nsCOMPtr<nsIDOMEvent> event = aVisitor.mDOMEvent;
+    if (!event) {
+      event = EventDispatcher::CreateEvent(aVisitor.mEvent->mOriginalTarget,
+                                           aVisitor.mPresContext,
+                                           aVisitor.mEvent, EmptyString());
+    }
 
-  if (IsFrozen() && event) {
     QueueEvent(event);
 
     aVisitor.mCanHandle = false;
     aVisitor.mParentTarget = nullptr;
     return NS_OK;
   }
 
   return DOMEventTargetHelper::PreHandleEvent(aVisitor);