Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElectronNET.API.Entities.WebPreferences.ContextIsolation [DefaultValue(true)] #411

Closed
freosc opened this issue May 21, 2020 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@freosc
Copy link
Contributor

freosc commented May 21, 2020

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.

@freosc freosc added the bug label May 21, 2020
@GregorBiswanger GregorBiswanger added this to the 8.31.3 milestone May 21, 2020
@GregorBiswanger GregorBiswanger self-assigned this May 21, 2020
GregorBiswanger added a commit that referenced this issue May 21, 2020
@GregorBiswanger
Copy link
Member

Fixed with the Electron.NET 8.31.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants