1'use strict'; 2 3const common = require('../common'); 4const EventEmitter = require('events'); 5const assert = require('assert'); 6 7const ee = new EventEmitter(); 8const handler = () => {}; 9 10assert.deepStrictEqual(ee.eventNames(), []); 11 12assert.strictEqual(ee._events.hasOwnProperty, undefined); 13assert.strictEqual(ee._events.toString, undefined); 14 15ee.on('__proto__', handler); 16ee.on('__defineGetter__', handler); 17ee.on('toString', handler); 18 19assert.deepStrictEqual(ee.eventNames(), [ 20 '__proto__', 21 '__defineGetter__', 22 'toString', 23]); 24 25assert.deepStrictEqual(ee.listeners('__proto__'), [handler]); 26assert.deepStrictEqual(ee.listeners('__defineGetter__'), [handler]); 27assert.deepStrictEqual(ee.listeners('toString'), [handler]); 28 29ee.on('__proto__', common.mustCall(function(val) { 30 assert.strictEqual(val, 1); 31})); 32ee.emit('__proto__', 1); 33 34process.on('__proto__', common.mustCall(function(val) { 35 assert.strictEqual(val, 1); 36})); 37process.emit('__proto__', 1); 38