summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJordan Harband <ljharb@gmail.com>2019-02-19 16:00:06 -0800
committerAnna Henningsen <anna@addaleax.net>2019-03-13 00:07:42 +0000
commit377c5835e8bfcd04273f24a244b2ba4aff76a27c (patch)
tree1595f9d38542b82502761b4ba802ce36fb5b3135 /test
parent8cbbe73553d2c623f2528350062d57dbf5305246 (diff)
downloadandroid-node-v8-377c5835e8bfcd04273f24a244b2ba4aff76a27c.tar.gz
android-node-v8-377c5835e8bfcd04273f24a244b2ba4aff76a27c.tar.bz2
android-node-v8-377c5835e8bfcd04273f24a244b2ba4aff76a27c.zip
domain: set `.domain` non-enumerable on resources
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>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-domain-add-remove.js4
-rw-r--r--test/parallel/test-domain-async-id-map-leak.js3
-rw-r--r--test/parallel/test-domain-implicit-binding.js2
-rw-r--r--test/parallel/test-domain-timer.js2
4 files changed, 11 insertions, 0 deletions
diff --git a/test/parallel/test-domain-add-remove.js b/test/parallel/test-domain-add-remove.js
index 8e1d082125..eb6503f2b9 100644
--- a/test/parallel/test-domain-add-remove.js
+++ b/test/parallel/test-domain-add-remove.js
@@ -4,6 +4,7 @@ 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();
@@ -11,6 +12,7 @@ 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;
@@ -19,8 +21,10 @@ 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);
diff --git a/test/parallel/test-domain-async-id-map-leak.js b/test/parallel/test-domain-async-id-map-leak.js
index e720241841..8c03aa9401 100644
--- a/test/parallel/test-domain-async-id-map-leak.js
+++ b/test/parallel/test-domain-async-id-map-leak.js
@@ -6,6 +6,7 @@ const assert = require('assert');
const async_hooks = require('async_hooks');
const domain = require('domain');
const EventEmitter = require('events');
+const isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable);
// This test makes sure that the (async id → domain) map which is part of the
// domain module does not get in the way of garbage collection.
@@ -21,7 +22,9 @@ d.run(() => {
emitter.linkToResource = resource;
assert.strictEqual(emitter.domain, d);
+ assert.strictEqual(isEnumerable(emitter, 'domain'), false);
assert.strictEqual(resource.domain, d);
+ assert.strictEqual(isEnumerable(resource, 'domain'), false);
// This would otherwise be a circular chain now:
// emitter → resource → async id ⇒ domain → emitter.
diff --git a/test/parallel/test-domain-implicit-binding.js b/test/parallel/test-domain-implicit-binding.js
index 13c146e4d7..15f6685df9 100644
--- a/test/parallel/test-domain-implicit-binding.js
+++ b/test/parallel/test-domain-implicit-binding.js
@@ -4,6 +4,7 @@ const common = require('../common');
const assert = require('assert');
const domain = require('domain');
const fs = require('fs');
+const isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable);
{
const d = new domain.Domain();
@@ -11,6 +12,7 @@ const fs = require('fs');
d.on('error', common.mustCall((err) => {
assert.strictEqual(err.message, 'foobar');
assert.strictEqual(err.domain, d);
+ assert.strictEqual(isEnumerable(err, 'domain'), false);
assert.strictEqual(err.domainEmitter, undefined);
assert.strictEqual(err.domainBound, undefined);
assert.strictEqual(err.domainThrown, true);
diff --git a/test/parallel/test-domain-timer.js b/test/parallel/test-domain-timer.js
index 67910e3d5b..5d288489e3 100644
--- a/test/parallel/test-domain-timer.js
+++ b/test/parallel/test-domain-timer.js
@@ -3,12 +3,14 @@
const common = require('../common');
const assert = require('assert');
const domain = require('domain');
+const isEnumerable = Function.call.bind(Object.prototype.propertyIsEnumerable);
const d = new domain.Domain();
d.on('error', common.mustCall((err) => {
assert.strictEqual(err.message, 'foobar');
assert.strictEqual(err.domain, d);
+ assert.strictEqual(isEnumerable(err, 'domain'), false);
assert.strictEqual(err.domainEmitter, undefined);
assert.strictEqual(err.domainBound, undefined);
assert.strictEqual(err.domainThrown, true);