Skip to content

Commit 15609e9

Browse files
committed
worker: throw InvalidStateError in postMessage after close
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.
1 parent 0f02810 commit 15609e9

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

lib/internal/worker/io.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ class BroadcastChannel extends EventTarget {
402402
if (arguments.length === 0)
403403
throw new ERR_MISSING_ARGS('message');
404404
if (this[kHandle] === undefined)
405-
throw new DOMException('BroadcastChannel is closed.');
405+
throw new DOMException('BroadcastChannel is closed.', 'InvalidStateError');
406406
if (this[kHandle].postMessage(message) === undefined)
407407
throw new DOMException('Message could not be posted.');
408408
}

test/wpt/status/webmessaging/broadcastchannel.json

-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
]
1111
}
1212
},
13-
"interface.any.js": {
14-
"fail": {
15-
"expected": [
16-
"postMessage after close should throw",
17-
"postMessage should throw InvalidStateError after close, even with uncloneable data"
18-
]
19-
}
20-
},
2113
"origin.window.js": {
2214
"fail": {
2315
"expected": [

0 commit comments

Comments
 (0)