webPreferences not working in BrowserViews #27698
Labels
11-x-y
blocked/need-info ❌
Cannot proceed without more information
bug 🪲
component/BrowserView
has-repro-gist
Issue can be reproduced with code at https://gist.github.com/
platform/macOS
stale
Preflight Checklist
Issue Details
v11.2.3
macOS 10.14.6
Unknown...
Expected Behavior
BrowserView
should inheritBrowserWindow
properties. I am able to use usewebPreferences
preload
option to inject a script when using only 1BrowserWindow
but if I set 1BrowserWindow
and then addBrowserViews
usingaddBrowserView
method thewebPreferences
options don't seem to be respected.I can't have the
preload
to work and even if I put the js in my local html render file the noderequire
and other node apis are not available/not found, and even if the js file only has aconsole.log
oralert
nothing happens, thepreload
file orscript src
file is not loaded correctly.And setting
nodeIntegration
to true does not work either, it seems thatwebPreferences
are just not respected inBrowserView
.Actual Behavior
BrowserView
options, specificallywebPreferences
should be respected. One should be able to usepreload
andnodeIntegration
options in anyBrowserWindow
orBrowserView
.To Reproduce
https://github.com/laranjaquadrada/electron-quick-start/blob/master/main.js
https://github.com/laranjaquadrada/electron-quick-start/blob/master/preload.js
Additional Information
This issue was reported previously as
preload not working in BrowserView
and closed due to issues in the preload file reference location.But I confirmed that is not the issue since the exact same options definition works in a project with only 1
BrowserWindow
.To me never works when set in one attached
BrowserView
, or multiple addedBrowserViews
.This bug was also mentioned in
stackoverflow
in November, last year: https://stackoverflow.com/a/64676851/4561667The text was updated successfully, but these errors were encountered: