Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageEvent#ports should contain transferred ports #37358

Closed
targos opened this issue Feb 13, 2021 · 1 comment
Closed

MessageEvent#ports should contain transferred ports #37358

targos opened this issue Feb 13, 2021 · 1 comment
Labels
worker Issues and PRs related to Worker support.

Comments

@targos
Copy link
Member

targos commented Feb 13, 2021

The following test currently fails:

'use strict';

const assert = require('assert');

const channel = new MessageChannel();
channel.port2.onmessage = function(event) {
  assert.strictEqual(event.ports.length, 1);
};

const channel2 = new MessageChannel();

channel.port1.postMessage('', [channel2.port1]);

Reference: https://html.spec.whatwg.org/multipage/comms.html#dom-messageevent-ports

@targos targos added the worker Issues and PRs related to Worker support. label Feb 13, 2021
@jasnell
Copy link
Member

jasnell commented Feb 22, 2021

/cc @addaleax

addaleax added a commit to addaleax/node that referenced this issue Feb 27, 2021
Add `ev.ports` for spec compliancy.

Since we only emit the raw `data` value, and only create the
`MessageEvent` instance if there are EventTarget-style listeners,
we store the ports list temporarily on the MessagePort object itself,
so that we can look it up when we need to create the event object.

Fixes: nodejs#37358
danielleadams pushed a commit that referenced this issue Mar 16, 2021
Add `ev.ports` for spec compliancy.

Since we only emit the raw `data` value, and only create the
`MessageEvent` instance if there are EventTarget-style listeners,
we store the ports list temporarily on the MessagePort object itself,
so that we can look it up when we need to create the event object.

Fixes: #37358

PR-URL: #37538
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
worker Issues and PRs related to Worker support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants