aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-process-emit.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2016-01-21 13:07:25 -0500
committercjihrig <cjihrig@gmail.com>2016-01-21 15:17:38 -0500
commit66cb4bcf0c032adc0f6abf7452150875c8a82243 (patch)
treea294ec79b21740de9caf9f8f172647d84e166dce /test/parallel/test-process-emit.js
parente4362728974ca7f46cbf92abc09d071d195d849f (diff)
downloadandroid-node-v8-66cb4bcf0c032adc0f6abf7452150875c8a82243.tar.gz
android-node-v8-66cb4bcf0c032adc0f6abf7452150875c8a82243.tar.bz2
android-node-v8-66cb4bcf0c032adc0f6abf7452150875c8a82243.zip
process: support symbol events
Event emitters support symbols as event names. The process object assumes that the event name is a string, and examines the first three characters to check for signals. This causes an exception if the event name is a symbol. This commit ensures that the event name is a string before trying to slice() it. PR-URL: https://github.com/nodejs/node/pull/4798 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Michaƫl Zasso <mic.besace@gmail.com> Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Diffstat (limited to 'test/parallel/test-process-emit.js')
-rw-r--r--test/parallel/test-process-emit.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/parallel/test-process-emit.js b/test/parallel/test-process-emit.js
new file mode 100644
index 0000000000..0e6d28b22a
--- /dev/null
+++ b/test/parallel/test-process-emit.js
@@ -0,0 +1,20 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const sym = Symbol();
+
+process.on('normal', common.mustCall(data => {
+ assert.strictEqual(data, 'normalData');
+}));
+
+process.on(sym, common.mustCall(data => {
+ assert.strictEqual(data, 'symbolData');
+}));
+
+process.on('SIGPIPE', common.mustCall(data => {
+ assert.strictEqual(data, 'signalData');
+}));
+
+process.emit('normal', 'normalData');
+process.emit(sym, 'symbolData');
+process.emit('SIGPIPE', 'signalData');