Bug 1964075 - use the correct EventTarget when creating a MessageEvent, r=baku

Differential Revision: https://phabricator.services.mozilla.com/D248270
This commit is contained in:
Olli Pettay
2025-05-07 20:30:27 +00:00
committed by opettay@mozilla.com
parent ee3ece049c
commit fde50e8b1f
2 changed files with 11 additions and 10 deletions

View File

@@ -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<nsString, 1> 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<nsString, 1> params;
GetType(*params.AppendElement());
doc->WarnOnceAbout(Document::ePreventDefaultFromPassiveListener,
false, params);
}
}
}
}

View File

@@ -119,8 +119,7 @@ class PostMessageRunnable final : public CancelableRunnable {
}
// Create the event
RefPtr<MessageEvent> event =
new MessageEvent(mPort->GetOwnerWindow(), nullptr, nullptr);
RefPtr<MessageEvent> event = new MessageEvent(mPort, nullptr, nullptr);
Sequence<OwningNonNull<MessagePort>> ports;
if (!mData->TakeTransferredPortsAsSequence(ports)) {