Test that MessagePort owners are current, not incumbent#24566
Test that MessagePort owners are current, not incumbent#24566
Conversation
The "owner" of a MessagePort is set a lot, but only *used* for determining what document (if any) should be associated with that MessagePort's tasks. I.e., it ensures that when that document becomes not-fully-active, the tasks are not run. Tests [1] show that the use of incumbent settings object for the owner of MessageChannel-created MessagePorts was incorrect. In fact, the current settings object is used. This allows for a dramatic simplification, as it means that the MessagePort's owner is always equal to its relevant settings object. Thus, we can entirely delete the owner concept, and the associated specialized "create a new MessagePort object" algorithm. This does require tweaking the examples of how the incumbent concept works, now that a simple constructor is no longer available to demonstrate the point. This also modernizes the definition of MessageChannel. Closes #4340. Helps with #1430. [1]: web-platform-tests/wpt#24566
The "owner" of a MessagePort is set a lot, but only *used* for determining what document (if any) should be associated with that MessagePort's tasks. I.e., it ensures that when that document becomes not-fully-active, the tasks are not run. Tests [1] show that the use of incumbent settings object for the owner of MessageChannel-created MessagePorts was incorrect. In fact, the current settings object is used. This allows for a dramatic simplification, as it means that the MessagePort's owner is always equal to its relevant settings object. Thus, we can entirely delete the owner concept, and the associated specialized "create a new MessagePort object" algorithm. This does require tweaking the examples of how the incumbent concept works, now that a simple constructor is no longer available to demonstrate the point. This also modernizes the definition of MessageChannel. Closes #4340. Helps with #1430. [1]: web-platform-tests/wpt#24566
| messageChannel.port1.onmessageerror = t.unreached_func("messageerror event recieved"); | ||
| messageChannel.port2.postMessage("boo"); | ||
|
|
||
| await new Promise(resolve => t.step_timeout(resolve, 3000)); |
There was a problem hiding this comment.
If you create another messageChannel in the entry global and use that, can we expect anything about its speed relative to the other one? That might allow using less resources on CI.
There was a problem hiding this comment.
I don't believe so, because each MessagePort has its own independent message queue, with no ordering guarantees between them. (Unlike BroadcastChannel.)
There was a problem hiding this comment.
I think it would be good to have a comment here explaining the timeout so those looking into removing timeouts know roughly what kind of API would have to exist.
|
For test(() => {
const c = new self[0].MessageChannel();
let obj = c.port1;
assert_global(obj);
obj = Object.getOwnPropertyDescriptor(MessageChannel.prototype, "port1").get.call(c);
assert_global(obj);
}, "MessageChannel's ports");to convince myself current and relevant are indeed the same for constructors. All browsers pass this so I'm not sure it's worth adding. |
The "owner" of a MessagePort is set a lot, but only *used* for determining what document (if any) should be associated with that MessagePort's tasks. I.e., it ensures that when that document becomes not-fully-active, the tasks are not run. Tests [1] show that the use of incumbent settings object for the owner of MessageChannel-created MessagePorts was incorrect. In fact, the current settings object (or relevant settings object of this) is used. This allows for a dramatic simplification, as it means that the MessagePort's owner is always equal to its relevant settings object. Thus, we can entirely delete the owner concept, and the associated specialized "create a new MessagePort object" algorithm. This does require tweaking the examples of how the incumbent concept works, now that a simple constructor is no longer available to demonstrate the point. This also modernizes the definition of MessageChannel. Closes #4340. Helps with #1430. [1]: web-platform-tests/wpt#24566
| messageChannel.port1.onmessageerror = t.unreached_func("messageerror event recieved"); | ||
| messageChannel.port2.postMessage("boo"); | ||
|
|
||
| await new Promise(resolve => t.step_timeout(resolve, 3000)); |
There was a problem hiding this comment.
I think it would be good to have a comment here explaining the timeout so those looking into removing timeouts know roughly what kind of API would have to exist.
The "owner" of a MessagePort is set a lot, but only *used* for determining what document (if any) should be associated with that MessagePort's tasks. I.e., it ensures that when that document becomes not-fully-active, the tasks are not run. Tests [1] show that the use of incumbent settings object for the owner of MessageChannel-created MessagePorts was incorrect. In fact, the current settings object (or relevant settings object of this) is used. This allows for a dramatic simplification, as it means that the MessagePort's owner is always equal to its relevant settings object. Thus, we can entirely delete the owner concept, and the associated specialized "create a new MessagePort object" algorithm. This does require tweaking the examples of how the incumbent concept works, now that a simple constructor is no longer available to demonstrate the point. This also modernizes the definition of MessageChannel. Closes whatwg#4340. Helps with whatwg#1430. [1]: web-platform-tests/wpt#24566
Follows whatwg/html#5728.