Default hasUserGesture to false when null

This commit is contained in:
Kevin Sawicki 2017-03-06 10:51:17 -08:00
parent 6fcb784f6e
commit 6240e30be1

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)
ipcMain.once(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, function (event, error, result) {
if (error == null) {
resolve(result)
if (typeof callback === 'function') callback(result)
resolve(result)
} else {
reject(error)
}
@ -149,10 +149,17 @@ for (const method of webFrameMethodsWithResult) {
// WebContents has been loaded.
WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callback) {
const requestId = getNextId()
if (typeof hasUserGesture === 'function') {
// Shift.
callback = hasUserGesture
hasUserGesture = null
}
if (hasUserGesture == null) {
hasUserGesture = false
}
if (this.getURL() && !this.isLoadingMainFrame()) {
return asyncWebFrameMethods.call(this, requestId, 'executeJavaScript', callback, code, hasUserGesture)
} else {