diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index c639ca867911..4caeb7399283 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -462,14 +462,16 @@ void Event::PreventDefault(JSContext* aCx, CallerType aCallerType) { void Event::PreventDefaultInternal(bool aCalledByDefaultHandler, nsIPrincipal* aPrincipal) { if (mEvent->mFlags.mInPassiveListener) { - if (nsPIDOMWindowInner* win = mOwner->GetAsInnerWindow()) { - if (Document* doc = win->GetExtantDoc()) { - if (!doc->HasWarnedAbout( - Document::ePreventDefaultFromPassiveListener)) { - AutoTArray params; - GetType(*params.AppendElement()); - doc->WarnOnceAbout(Document::ePreventDefaultFromPassiveListener, - false, params); + if (mOwner) { + if (nsPIDOMWindowInner* win = mOwner->GetAsInnerWindow()) { + if (Document* doc = win->GetExtantDoc()) { + if (!doc->HasWarnedAbout( + Document::ePreventDefaultFromPassiveListener)) { + AutoTArray params; + GetType(*params.AppendElement()); + doc->WarnOnceAbout(Document::ePreventDefaultFromPassiveListener, + false, params); + } } } } diff --git a/dom/messagechannel/MessagePort.cpp b/dom/messagechannel/MessagePort.cpp index 417884c31b60..0f99e93607da 100644 --- a/dom/messagechannel/MessagePort.cpp +++ b/dom/messagechannel/MessagePort.cpp @@ -119,8 +119,7 @@ class PostMessageRunnable final : public CancelableRunnable { } // Create the event - RefPtr event = - new MessageEvent(mPort->GetOwnerWindow(), nullptr, nullptr); + RefPtr event = new MessageEvent(mPort, nullptr, nullptr); Sequence> ports; if (!mData->TakeTransferredPortsAsSequence(ports)) {