11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst EventEmitter = require('events'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci// Test emit called by other context 71cb0ef41Sopenharmony_ciconst EE = new EventEmitter(); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci// Works as expected if the context has no `constructor.name` 101cb0ef41Sopenharmony_ci{ 111cb0ef41Sopenharmony_ci const ctx = Object.create(null); 121cb0ef41Sopenharmony_ci assert.throws( 131cb0ef41Sopenharmony_ci () => EE.emit.call(ctx, 'error', new Error('foo')), 141cb0ef41Sopenharmony_ci common.expectsError({ name: 'Error', message: 'foo' }) 151cb0ef41Sopenharmony_ci ); 161cb0ef41Sopenharmony_ci} 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciassert.strictEqual(EE.emit.call({}, 'foo'), false); 19