From 2d173e6f707558e7b194874a942a99f980a5667f Mon Sep 17 00:00:00 2001 From: Dean Whillier Date: Mon, 9 Sep 2019 12:30:25 -0400 Subject: [PATCH] Enable context isolation (#999) --- src/main.js | 1 + src/main/mainWindow.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/main.js b/src/main.js index 330a0463..824602a5 100644 --- a/src/main.js +++ b/src/main.js @@ -355,6 +355,7 @@ function handleAppWillFinishLaunching() { function handleAppWebContentsCreated(dc, contents) { contents.on('will-attach-webview', (event, webPreferences) => { webPreferences.nodeIntegration = false; + webPreferences.contextIsolation = true; }); contents.on('will-navigate', (event, navigationUrl) => { const parsedUrl = new URL(navigationUrl); diff --git a/src/main/mainWindow.js b/src/main/mainWindow.js index 5793b59c..df02e923 100644 --- a/src/main/mainWindow.js +++ b/src/main/mainWindow.js @@ -45,6 +45,7 @@ function createMainWindow(config, options) { fullscreen: false, webPreferences: { nodeIntegration: true, + contextIsolation: false, webviewTag: true, }, }); @@ -71,6 +72,7 @@ function createMainWindow(config, options) { mainWindow.webContents.on('will-attach-webview', (event, webPreferences) => { webPreferences.nodeIntegration = false; + webPreferences.contextIsolation = true; }); mainWindow.once('ready-to-show', () => {