worker: add Symbol.toStringTag to BroadcastChannel

Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65532
Fixes: https://github.com/nodejs/node/issues/65527
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Lazizbek Ergashev authored and Filip Skokan committed 2026-09-27 00:37:26 +02:00
1 parent b456adbcd6
commit cd908df27f
2 files changed
+16 -1

No files matched your search

+11
View File
@@ -211,12 +211,16 @@ ObjectDefineProperty(MessagePort.prototype, inspect.custom, {
ObjectDefineProperty(MessagePort.prototype, SymbolToStringTag, {
__proto__: null,
writable: false,
enumerable: false,
configurable: true,
value: 'MessagePort',
});
ObjectDefineProperty(MessageChannel.prototype, SymbolToStringTag, {
__proto__: null,
writable: false,
enumerable: false,
configurable: true,
value: 'MessageChannel',
});
@@ -474,6 +478,13 @@ class BroadcastChannel extends EventTarget {
}
ObjectDefineProperties(BroadcastChannel.prototype, {
[SymbolToStringTag]: {
__proto__: null,
writable: false,
enumerable: false,
configurable: true,
value: 'BroadcastChannel',
},
name: kEnumerableProperty,
close: kEnumerableProperty,
postMessage: kEnumerableProperty,
@@ -4,7 +4,7 @@ require('../common');
const assert = require('assert');
const classesToBeTested = [ MessageChannel, MessagePort ];
const classesToBeTested = [ MessageChannel, MessagePort, BroadcastChannel ];
classesToBeTested.forEach((cls) => {
assert.strictEqual(cls.prototype[Symbol.toStringTag], cls.name);
@@ -15,3 +15,7 @@ classesToBeTested.forEach((cls) => {
const channel = new MessageChannel();
assert.strictEqual(Object.prototype.toString.call(channel), '[object MessageChannel]');
assert.strictEqual(Object.prototype.toString.call(channel.port1), '[object MessagePort]');
const broadcastChannel = new BroadcastChannel('string-tag');
assert.strictEqual(Object.prototype.toString.call(broadcastChannel), '[object BroadcastChannel]');
broadcastChannel.close();