Enable context isolation (#999)

This commit is contained in:
Dean Whillier
2019-09-09 12:30:25 -04:00
committed by GitHub
parent 304d26cece
commit 2d173e6f70
2 changed files with 3 additions and 0 deletions

View File

@@ -355,6 +355,7 @@ function handleAppWillFinishLaunching() {
function handleAppWebContentsCreated(dc, contents) { function handleAppWebContentsCreated(dc, contents) {
contents.on('will-attach-webview', (event, webPreferences) => { contents.on('will-attach-webview', (event, webPreferences) => {
webPreferences.nodeIntegration = false; webPreferences.nodeIntegration = false;
webPreferences.contextIsolation = true;
}); });
contents.on('will-navigate', (event, navigationUrl) => { contents.on('will-navigate', (event, navigationUrl) => {
const parsedUrl = new URL(navigationUrl); const parsedUrl = new URL(navigationUrl);

View File

@@ -45,6 +45,7 @@ function createMainWindow(config, options) {
fullscreen: false, fullscreen: false,
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,
contextIsolation: false,
webviewTag: true, webviewTag: true,
}, },
}); });
@@ -71,6 +72,7 @@ function createMainWindow(config, options) {
mainWindow.webContents.on('will-attach-webview', (event, webPreferences) => { mainWindow.webContents.on('will-attach-webview', (event, webPreferences) => {
webPreferences.nodeIntegration = false; webPreferences.nodeIntegration = false;
webPreferences.contextIsolation = true;
}); });
mainWindow.once('ready-to-show', () => { mainWindow.once('ready-to-show', () => {