Skip to content
Permalink
Browse files

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 <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information...
bengl authored and addaleax committed Oct 26, 2016
1 parent 2141d37 commit e0bc5a7361b1d29c3ed034155fd779ce6f44fb13
Showing with 17 additions and 3 deletions.
  1. +2 −3 lib/internal/bootstrap_node.js
  2. +15 −0 test/parallel/test-process-prototype.js
@@ -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);
@@ -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);

0 comments on commit e0bc5a7

Please sign in to comment.
You can’t perform that action at this time.