diff --git a/test/parallel/test-event-emitter-prototype-bleeding.js b/test/parallel/test-event-emitter-prototype-bleeding.js new file mode 100644 index 00000000000000..892e9e8d18a36e --- /dev/null +++ b/test/parallel/test-event-emitter-prototype-bleeding.js @@ -0,0 +1,23 @@ +'use strict'; +var util = require('util'); +var assert = require('assert'); +var EventEmitter = require('events').EventEmitter; +var called = false; + +function TestClass() { +} +TestClass.prototype = new EventEmitter(); + +function okListener() { + called = true; +} +function brokenListener() { + throw new Error('This one should not be called!'); +} + +var ok = new TestClass(); +var broken = new TestClass(); +broken.on('end', okListener); +ok.on('end', brokenListener); +ok.emit('end'); +assert.ok(called, 'The ok listener should have been called');