Add default error handler to remote promises (#6151)
* Add failing spec for unhandled main process exception * Remove unused return * Use let/const instead of var * Add spec for unhandled rejection in renderer process * Prevent unhandled rejection defaul * Use once instead of on * Add default fulfilled/rejection handler to promise
This commit is contained in:
parent
74321dce74
commit
8a9f2261d0
3 changed files with 43 additions and 10 deletions
|
@ -126,6 +126,33 @@ describe('ipc module', function () {
|
|||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('does not emit unhandled rejection events in the main process', function (done) {
|
||||
remote.process.once('unhandledRejection', function (reason) {
|
||||
done(reason)
|
||||
})
|
||||
|
||||
var promise = remote.require(path.join(fixtures, 'module', 'unhandled-rejection.js'))
|
||||
promise.reject().then(function () {
|
||||
done(new Error('Promise was not rejected'))
|
||||
}).catch(function (error) {
|
||||
assert.equal(error.message, 'rejected')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('emits unhandled rejection events in the renderer process', function (done) {
|
||||
window.addEventListener('unhandledrejection', function (event) {
|
||||
event.preventDefault()
|
||||
assert.equal(event.reason.message, 'rejected')
|
||||
done()
|
||||
})
|
||||
|
||||
var promise = remote.require(path.join(fixtures, 'module', 'unhandled-rejection.js'))
|
||||
promise.reject().then(function () {
|
||||
done(new Error('Promise was not rejected'))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('remote webContents', function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue