GeezerVison is showing github.com — worker: add Symbol.toStringTag to BroadcastChannel · nodejs/node@78b502a
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/worker/io.js +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -211,12 +211,16 @@ ObjectDefineProperty(MessagePort.prototype, inspect.custom, { | 211 | 211 |
| 212 | 212 | ObjectDefineProperty(MessagePort.prototype, SymbolToStringTag, { | 213 | 213 | __proto__: null, | | 214 | + writable: false, | | 215 | + enumerable: false, | 214 | 216 | configurable: true, | 215 | 217 | value: 'MessagePort', | 216 | 218 | }); | 217 | 219 |
| 218 | 220 | ObjectDefineProperty(MessageChannel.prototype, SymbolToStringTag, { | 219 | 221 | __proto__: null, | | 222 | + writable: false, | | 223 | + enumerable: false, | 220 | 224 | configurable: true, | 221 | 225 | value: 'MessageChannel', | 222 | 226 | }); | @@ -474,6 +478,13 @@ class BroadcastChannel extends EventTarget { | 474 | 478 | } | 475 | 479 |
| 476 | 480 | ObjectDefineProperties(BroadcastChannel.prototype, { | | 481 | + [SymbolToStringTag]: { | | 482 | + __proto__: null, | | 483 | + writable: false, | | 484 | + enumerable: false, | | 485 | + configurable: true, | | 486 | + value: 'BroadcastChannel', | | 487 | + }, | 477 | 488 | name: kEnumerableProperty, | 478 | 489 | close: kEnumerableProperty, | 479 | 490 | postMessage: kEnumerableProperty, | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-messaging-string-tag.js +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,7 +4,7 @@ require('../common'); | 4 | 4 |
| 5 | 5 | const assert = require('assert'); | 6 | 6 |
| 7 | | -const classesToBeTested = [ MessageChannel, MessagePort ]; | | 7 | +const classesToBeTested = [ MessageChannel, MessagePort, BroadcastChannel ]; | 8 | 8 |
| 9 | 9 | classesToBeTested.forEach((cls) => { | 10 | 10 | assert.strictEqual(cls.prototype[Symbol.toStringTag], cls.name); | @@ -15,3 +15,7 @@ classesToBeTested.forEach((cls) => { | 15 | 15 | const channel = new MessageChannel(); | 16 | 16 | assert.strictEqual(Object.prototype.toString.call(channel), '[object MessageChannel]'); | 17 | 17 | assert.strictEqual(Object.prototype.toString.call(channel.port1), '[object MessagePort]'); | | 18 | + | | 19 | +const broadcastChannel = new BroadcastChannel('string-tag'); | | 20 | +assert.strictEqual(Object.prototype.toString.call(broadcastChannel), '[object BroadcastChannel]'); | | 21 | +broadcastChannel.close(); |
|