GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — worker: add Symbol.toStringTag to MessageChannel and MessagePort · nodejs/node@f6f705e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/worker
    • io.js
  • test/parallel
    • test-eventtarget-memoryleakwarning.js
    • test-messagechannel-string-tag.js
    • test-worker-message-port-inspect-during-init-hook.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/worker/io.js‎

Copy file name to clipboardExpand all lines: lib/internal/worker/io.js
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const {
1515
ReflectApply,
1616
Symbol,
1717
SymbolFor,
18+
SymbolToStringTag,
1819
} = primordials;
1920

2021
const {
@@ -208,6 +209,18 @@ ObjectDefineProperty(MessagePort.prototype, inspect.custom, {
208209
},
209210
});
210211

212+
ObjectDefineProperty(MessagePort.prototype, SymbolToStringTag, {
213+
__proto__: null,
214+
configurable: true,
215+
value: 'MessagePort',
216+
});
217+
218+
ObjectDefineProperty(MessageChannel.prototype, SymbolToStringTag, {
219+
__proto__: null,
220+
configurable: true,
221+
value: 'MessageChannel',
222+
});
223+
211224
function setupPortReferencing(port, eventEmitter, eventName) {
212225
// Keep track of whether there are any workerMessage listeners:
213226
// If there are some, ref() the channel so it keeps the event loop alive.
Collapse file

‎test/parallel/test-eventtarget-memoryleakwarning.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-eventtarget-memoryleakwarning.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ common.expectWarning({
1515
'EventTarget. MaxListeners is 2. Use events.setMaxListeners() ' +
1616
'to increase limit'],
1717
['Possible EventTarget memory leak detected. 3 foo listeners added to ' +
18-
'[MessagePort [EventTarget]]. ' +
18+
'[MessagePort]. ' +
1919
'MaxListeners is 2. ' +
2020
'Use events.setMaxListeners() to increase ' +
2121
'limit'],
2222
['Possible EventTarget memory leak detected. 3 foo listeners added to ' +
23-
'[MessagePort [EventTarget]]. ' +
23+
'[MessagePort]. ' +
2424
'MaxListeners is 2. ' +
2525
'Use events.setMaxListeners() to increase ' +
2626
'limit'],
Collapse file

‎test/parallel/test-messagechannel-string-tag.js‎

Copy file name to clipboard
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
require('../common');
4+
5+
const assert = require('assert');
6+
7+
const classesToBeTested = [ MessageChannel, MessagePort ];
8+
9+
classesToBeTested.forEach((cls) => {
10+
assert.strictEqual(cls.prototype[Symbol.toStringTag], cls.name);
11+
assert.deepStrictEqual(Object.getOwnPropertyDescriptor(cls.prototype, Symbol.toStringTag),
12+
{ configurable: true, enumerable: false, value: cls.name, writable: false });
13+
});
14+
15+
const channel = new MessageChannel();
16+
assert.strictEqual(Object.prototype.toString.call(channel), '[object MessageChannel]');
17+
assert.strictEqual(Object.prototype.toString.call(channel.port1), '[object MessagePort]');
Collapse file

‎test/parallel/test-worker-message-port-inspect-during-init-hook.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-worker-message-port-inspect-during-init-hook.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async_hooks.createHook({
1212
init: common.mustCall((id, type, triggerId, resource) => {
1313
assert.strictEqual(
1414
util.inspect(resource),
15-
'MessagePort [EventTarget] { active: true, refed: false }');
15+
'MessagePort { active: true, refed: false }');
1616
}, 2)
1717
}).enable();
1818

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.