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

webPreferences not working in BrowserViews #27698

Closed
laranjaquadrada opened this issue Feb 10, 2021 · 5 comments
Closed

webPreferences not working in BrowserViews #27698

laranjaquadrada opened this issue Feb 10, 2021 · 5 comments
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

Comments

@laranjaquadrada
Copy link

laranjaquadrada commented Feb 10, 2021

Preflight Checklist

  • [ X ] I have read the Contributing Guidelines for this project.
  • [ X ] I agree to follow the Code of Conduct that this project adheres to.
  • [ X ] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    v11.2.3
  • Operating System:
    macOS 10.14.6
  • Last Known Working Electron version:
    Unknown...

Expected Behavior

BrowserView should inherit BrowserWindow properties. I am able to use use webPreferences preload option to inject a script when using only 1 BrowserWindow but if I set 1 BrowserWindow and then add BrowserViews using addBrowserView method the webPreferences 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 node require and other node apis are not available/not found, and even if the js file only has a console.log or alert nothing happens, the preload file or script src file is not loaded correctly.

And setting nodeIntegration to true does not work either, it seems that webPreferences are just not respected in BrowserView.

Actual Behavior

BrowserView options, specifically webPreferences should be respected. One should be able to use preload and nodeIntegration options in any BrowserWindow or BrowserView.

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 added BrowserViews.

This bug was also mentioned in stackoverflow in November, last year: https://stackoverflow.com/a/64676851/4561667

@laranjaquadrada laranjaquadrada changed the title Preload not working in BrowserViews webPreferences not working in BrowserViews Feb 11, 2021
@ckerr
Copy link
Member

ckerr commented Feb 11, 2021

@ckerr ckerr added 11-x-y bug 🪲 component/BrowserView has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/macOS labels Feb 11, 2021
@laranjaquadrada
Copy link
Author

Thanks @ckerr ! What are the next steps from this? Do you think this bug can be addressed soon?

Currently my work around in my app is to use two distinct BrowserWindows that open separately but I really would like to have it all in just one application window using the layout split with BrowserViews...

Any expectation to when the dev team can pick this up and when should I expect it to be solved in a new electron release?

@nornagon
Copy link
Member

nornagon commented Jul 6, 2021

I'm confused about the example, which includes this snippet:

  mainView.setBounds({
    x: 0,
    y: 0,
    width: 961,
    height: 800,
    minWidth: 665,
    webPreferences: {
      preload: path.join(__dirname, '/preload.js'), //this does not work!
      nodeIntegration: true //This does not seem to work either
    }
  });

setBounds() does not take webPreferences as an option, so it's not surprising that this has no effect.

@nornagon nornagon added the blocked/need-info ❌ Cannot proceed without more information label Jul 6, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Oct 6, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2022

This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants