Skip to content

Commit 2462fd8

Browse files
benglMylesBorins
authored andcommitted
process: maintain constructor descriptor
Use the original property descriptor instead of just taking the value, which would, by default, be non-writable and non-configurable. PR-URL: #9306 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 7aeeee3 commit 2462fd8

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/internal/bootstrap_node.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
const EventEmitter = NativeModule.require('events');
1414
process._eventsCount = 0;
1515

16+
const origProcProto = Object.getPrototypeOf(process);
1617
Object.setPrototypeOf(process, Object.create(EventEmitter.prototype, {
17-
constructor: {
18-
value: process.constructor
19-
}
18+
constructor: Object.getOwnPropertyDescriptor(origProcProto, 'constructor')
2019
}));
2120

2221
EventEmitter.call(process);
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const EventEmitter = require('events');
5+
6+
const proto = Object.getPrototypeOf(process);
7+
8+
assert(proto instanceof EventEmitter);
9+
10+
const desc = Object.getOwnPropertyDescriptor(proto, 'constructor');
11+
12+
assert.strictEqual(desc.value, process.constructor);
13+
assert.strictEqual(desc.writable, true);
14+
assert.strictEqual(desc.enumerable, false);
15+
assert.strictEqual(desc.configurable, true);

0 commit comments

Comments
 (0)