Ensure the callback is a function when executing JS

This commit is contained in:
Samuel Attard 2017-02-23 09:55:05 +11:00 committed by Kevin Sawicki
parent f549bda9fc
commit 095e79b043

View file

@ -115,8 +115,8 @@ const asyncWebFrameMethods = function (requestId, method, callback, ...args) {
this.send('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', requestId, method, args) this.send('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', requestId, method, args)
ipcMain.once(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, function (event, error, result) { ipcMain.once(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, function (event, error, result) {
if (error == null) { if (error == null) {
if (callback != null) callback(result)
resolve(result) resolve(result)
if (typeof callback === 'function') callback(result)
} else { } else {
reject(error) reject(error)
} }