mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
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:
1 parent
b456adbcd6
commit
cd908df27f
2 files changed
+16
-1
No files matched your search
@@ -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,
|
||||
|
||||
+5
-1
@@ -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();
|
||||
Reference in new issue
Block a user