From: Cheng Zhao Date: Wed, 17 Jul 2013 10:52:02 +0000 (+0800) Subject: Add two tests regarding crashes in context switching. X-Git-Tag: v0.1.2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=42a6a7d0d33f87d889cebc8d89aa37393dce6054;p=electron.git Add two tests regarding crashes in context switching. --- diff --git a/spec/node/contexts.coffee b/spec/node/contexts.coffee new file mode 100644 index 00000000..589b74a6 --- /dev/null +++ b/spec/node/contexts.coffee @@ -0,0 +1,21 @@ +assert = require 'assert' +fs = require 'fs' + +describe 'contexts', -> + describe 'setTimeout in fs callback', -> + it 'does not crash', (done) -> + fs.readFile __filename, -> + setTimeout done, 0 + + describe 'throw error in node context', -> + it 'get caught', (done) -> + error = new Error('boo!') + lsts = process.listeners 'uncaughtException' + process.removeAllListeners 'uncaughtException' + process.on 'uncaughtException', (err) -> + process.removeAllListeners 'uncaughtException' + for lst in lsts + process.on 'uncaughtException', lst + done() + fs.readFile __filename, -> + throw error