mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
377c5835e8
In particular, this comes into play in the node repl, which apparently enables domains by default. Whenever any Promise gets inspected, a `.domain` property is displayed, which is *very confusing*, especially since it has some kind of WeakReference attached to it, which is not yet a language feature. This change will prevent it from showing up in casual inspection, but will leave it available for use. PR-URL: https://github.com/nodejs/node/pull/26210 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
31 lines
913 B
JavaScript
31 lines
913 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const domain = require('domain');
|
|
const EventEmitter = require('events');
|
|
const isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable);
|
|
|
|
const d = new domain.Domain();
|
|
const e = new EventEmitter();
|
|
const e2 = new EventEmitter();
|
|
|
|
d.add(e);
|
|
assert.strictEqual(e.domain, d);
|
|
assert.strictEqual(isEnumerable(e, 'domain'), false);
|
|
|
|
// Adding the same event to a domain should not change the member count
|
|
let previousMemberCount = d.members.length;
|
|
d.add(e);
|
|
assert.strictEqual(previousMemberCount, d.members.length);
|
|
|
|
d.add(e2);
|
|
assert.strictEqual(e2.domain, d);
|
|
assert.strictEqual(isEnumerable(e2, 'domain'), false);
|
|
|
|
previousMemberCount = d.members.length;
|
|
d.remove(e2);
|
|
assert.notStrictEqual(e2.domain, d);
|
|
assert.strictEqual(isEnumerable(e2, 'domain'), false);
|
|
assert.strictEqual(previousMemberCount - 1, d.members.length);
|