diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 695ec8a4092..d363bb051b8 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -113,9 +113,12 @@ const asyncWebFrameMethods = function (requestId, method, callback, ...args) { return new Promise((resolve, reject) => { 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) { - if (callback && !error) callback(result) - if (error) return reject(error) - return resolve(result) + if (error == null) { + if (callback != null) callback(result) + resolve(result) + } else { + reject(error) + } }) }) }