Skip to content

Commit

Permalink
worker: throw InvalidStateError in postMessage after close
Browse files Browse the repository at this point in the history
Align BroadcastChannel behavior with the spec by throwing an
InvalidStateError when postMessage is called after the channel is
closed. This ensures that BroadcastChannel properly handles closed
states and throws the correct error for postMessage attempts.

This update addresses expected failures for invalid postMessage after close in WPT.
  • Loading branch information
Nahee-Park committed Oct 1, 2024
1 parent 0f02810 commit 15609e9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
2 changes: 1 addition & 1 deletion lib/internal/worker/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class BroadcastChannel extends EventTarget {
if (arguments.length === 0)
throw new ERR_MISSING_ARGS('message');
if (this[kHandle] === undefined)
throw new DOMException('BroadcastChannel is closed.');
throw new DOMException('BroadcastChannel is closed.', 'InvalidStateError');
if (this[kHandle].postMessage(message) === undefined)
throw new DOMException('Message could not be posted.');
}
Expand Down
8 changes: 0 additions & 8 deletions test/wpt/status/webmessaging/broadcastchannel.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
]
}
},
"interface.any.js": {
"fail": {
"expected": [
"postMessage after close should throw",
"postMessage should throw InvalidStateError after close, even with uncloneable data"
]
}
},
"origin.window.js": {
"fail": {
"expected": [
Expand Down

0 comments on commit 15609e9

Please sign in to comment.