From bd906ddda6e1b936f8c4bf3caa48b1c58a92a44c Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 26 May 2020 09:38:00 +0200 Subject: [PATCH] Enable contextIsolation on webviews --- frontend/ts/index.ts | 4 ++++ src/windows/MainWindow.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/ts/index.ts b/frontend/ts/index.ts index 5b499a6..f0eb02b 100644 --- a/frontend/ts/index.ts +++ b/frontend/ts/index.ts @@ -466,6 +466,10 @@ function loadService(serviceId: number, service: any) { service.view.setAttribute('autosize', 'true'); service.view.setAttribute('src', emptyPage); + // Enable context isolation. This is currently not used as there is no preload script; however it could prevent + // eventual future human mistakes. + service.view.setAttribute('webpreferences', 'contextIsolation=yes'); + // Append element to DOM document.querySelector('#services')?.appendChild(service.view); diff --git a/src/windows/MainWindow.ts b/src/windows/MainWindow.ts index dc3e6c4..59a708d 100644 --- a/src/windows/MainWindow.ts +++ b/src/windows/MainWindow.ts @@ -110,7 +110,7 @@ export default class MainWindow extends Window { this.serviceSettingsWindow.setup(); this.serviceSettingsWindow.onClose(() => { this.serviceSettingsWindow = undefined; - }) + }); } });