diff --git a/lib/renderer/init.js b/lib/renderer/init.js index b19ace73c81c..c65c6066b7cd 100644 --- a/lib/renderer/init.js +++ b/lib/renderer/init.js @@ -31,8 +31,8 @@ const ipcRenderer = require('@electron/internal/renderer/ipc-renderer-internal') require('@electron/internal/renderer/web-frame-init')() // Process command line arguments. -let nodeIntegration = 'false' -let webviewTag = 'false' +let nodeIntegration = false +let webviewTag = false let preloadScript = null let preloadScripts = [] let isBackgroundPage = false @@ -45,7 +45,7 @@ for (const arg of process.argv) { // This is a guest BrowserWindow. process.openerId = parseInt(arg.substr(arg.indexOf('=') + 1)) } else if (arg.indexOf('--node-integration=') === 0) { - nodeIntegration = arg.substr(arg.indexOf('=') + 1) + nodeIntegration = arg.substr(arg.indexOf('=') + 1) === 'true' } else if (arg.indexOf('--preload=') === 0) { preloadScript = arg.substr(arg.indexOf('=') + 1) } else if (arg === '--background-page') { @@ -53,7 +53,7 @@ for (const arg of process.argv) { } else if (arg.indexOf('--app-path=') === 0) { appPath = arg.substr(arg.indexOf('=') + 1) } else if (arg.indexOf('--webview-tag=') === 0) { - webviewTag = arg.substr(arg.indexOf('=') + 1) + webviewTag = arg.substr(arg.indexOf('=') + 1) === 'true' } else if (arg.indexOf('--preload-scripts') === 0) { preloadScripts = arg.substr(arg.indexOf('=') + 1).split(path.delimiter) } @@ -67,14 +67,14 @@ if (preloadScript) { if (window.location.protocol === 'chrome-devtools:') { // Override some inspector APIs. require('@electron/internal/renderer/inspector') - nodeIntegration = 'false' + nodeIntegration = false } else if (window.location.protocol === 'chrome-extension:') { // Add implementations of chrome API. require('@electron/internal/renderer/chrome-api').injectTo(window.location.hostname, isBackgroundPage, window) - nodeIntegration = 'false' + nodeIntegration = false } else if (window.location.protocol === 'chrome:') { // Disable node integration for chrome UI scheme. - nodeIntegration = 'false' + nodeIntegration = false } else { // Override default web functions. require('@electron/internal/renderer/override') @@ -83,13 +83,13 @@ if (window.location.protocol === 'chrome-devtools:') { require('@electron/internal/renderer/content-scripts-injector') // Load webview tag implementation. - if (webviewTag === 'true' && process.guestInstanceId == null) { + if (webviewTag && process.guestInstanceId == null) { require('@electron/internal/renderer/web-view/web-view') require('@electron/internal/renderer/web-view/web-view-attributes') } } -if (nodeIntegration === 'true') { +if (nodeIntegration) { // Export node bindings to global. global.require = require global.module = module @@ -157,7 +157,7 @@ for (const preloadScript of preloadScripts) { } // Warn about security issues -require('@electron/internal/renderer/security-warnings')(nodeIntegration === 'true') +require('@electron/internal/renderer/security-warnings')(nodeIntegration) // Report focus/blur events of webview to browser. // Note that while Chromium content APIs have observer for focus/blur, they