Description
I tested using Electron.net API and CLI 8.31.2
ElectronJS lists the WebPreferences.ContextIsolation default value as false ([https://www.electronjs.org/docs/api/browser-window]).
ElectronNet API decorates the WebPreferences.ContextIsolation property with [DefaultValue(true)] which results in not setting this value in WindowManager.CreateWindowAsync when serializing "options" to a Json object.
This is my ElectronBootstrap code:
BrowserWindowOptions options = new BrowserWindowOptions() {
Kiosk = true,
AutoHideMenuBar = true,
TitleBarStyle = TitleBarStyle.hidden,
WebPreferences = new WebPreferences {
NodeIntegration = false,
ContextIsolation = true, // protect against prototype pollution
Preload = System.IO.Path.Join(AppDomain.CurrentDomain.BaseDirectory, "preload.js")
}
};
doing so, results in this error in the browser:
init.ts:207 Error: contextBridge API can only be used when contextIsolation is enabled
at checkContextIsolationEnabled (context-bridge.ts:7)
at Object.exposeInMainWorld (context-bridge.ts:12)
When I remove the [DefaultValue(true)] decorator of the ContextIsolation property in the ElectronNet.Api, it seems to work as expected.