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: https://github.com/nodejs/node/pull/9306 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
2141d37452
commit
e0bc5a7361
5
lib/internal/bootstrap_node.js
vendored
5
lib/internal/bootstrap_node.js
vendored
@ -13,10 +13,9 @@
|
||||
const EventEmitter = NativeModule.require('events');
|
||||
process._eventsCount = 0;
|
||||
|
||||
const origProcProto = Object.getPrototypeOf(process);
|
||||
Object.setPrototypeOf(process, Object.create(EventEmitter.prototype, {
|
||||
constructor: {
|
||||
value: process.constructor
|
||||
}
|
||||
constructor: Object.getOwnPropertyDescriptor(origProcProto, 'constructor')
|
||||
}));
|
||||
|
||||
EventEmitter.call(process);
|
||||
|
15
test/parallel/test-process-prototype.js
Normal file
15
test/parallel/test-process-prototype.js
Normal file
@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const EventEmitter = require('events');
|
||||
|
||||
const proto = Object.getPrototypeOf(process);
|
||||
|
||||
assert(proto instanceof EventEmitter);
|
||||
|
||||
const desc = Object.getOwnPropertyDescriptor(proto, 'constructor');
|
||||
|
||||
assert.strictEqual(desc.value, process.constructor);
|
||||
assert.strictEqual(desc.writable, true);
|
||||
assert.strictEqual(desc.enumerable, false);
|
||||
assert.strictEqual(desc.configurable, true);
|
Loading…
x
Reference in New Issue
Block a user