Browse Source

fix: coerce executeJavaScript arguments (#24396)

Jeremy Rose 4 years ago
parent
commit
80a6adb597
1 changed files with 3 additions and 3 deletions
  1. 3 3
      lib/browser/api/web-contents.ts

+ 3 - 3
lib/browser/api/web-contents.ts

@@ -204,11 +204,11 @@ const waitTillCanExecuteJavaScript = async (webContents: WebContentsInternal) =>
 // WebContents has been loaded.
 WebContents.prototype.executeJavaScript = async function (code, hasUserGesture) {
   await waitTillCanExecuteJavaScript(this);
-  return ipcMainUtils.invokeInWebContents(this, false, 'ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', 'executeJavaScript', code, hasUserGesture);
+  return ipcMainUtils.invokeInWebContents(this, false, 'ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', 'executeJavaScript', String(code), !!hasUserGesture);
 };
-WebContents.prototype.executeJavaScriptInIsolatedWorld = async function (code, hasUserGesture) {
+WebContents.prototype.executeJavaScriptInIsolatedWorld = async function (worldId, code, hasUserGesture) {
   await waitTillCanExecuteJavaScript(this);
-  return ipcMainUtils.invokeInWebContents(this, false, 'ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', 'executeJavaScriptInIsolatedWorld', code, hasUserGesture);
+  return ipcMainUtils.invokeInWebContents(this, false, 'ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', 'executeJavaScriptInIsolatedWorld', worldId, code, !!hasUserGesture);
 };
 
 // Translate the options of printToPDF.