-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
feat: add exposeInIsolatedWorld(worldId, key, api) to contextBridge #34974
Conversation
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per my comment above, please undo all automated formatting changes in this PR not caused by our own linter as it makes the diff almost impossible to review accurately if a lot of the changed lines don't actually contain changes
I've updated this PR to remove all lining differences |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some parts of spec-main/api-context-bridge-spec.ts
still has the formatting changes.
The diff in the existing content from the spec file is because I had to create a separate Old structure of the spec file
New structure of the spec file
|
Haven't reviewed the code but API LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
Had some feedback about the code.
5cc0a94
to
d02a091
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code is looking good. Just had a small request for tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
all automated formatting changes have been removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Not sure what's going on with the cation bot, but this has LGTM API signoff from 3 API WG members so that is not blocking this PR |
Congrats on merging your first pull request! 🎉🎉🎉 |
Release Notes Persisted
|
The documentation is lacking a proper example of how to use |
…lectron#34974) * feat: add exposeInIsolatedWorld(worldId, key, api) to contextBridge * Updates exposeInIslatedWorld worldId documentation
I struggled with this as well, but I finally found some context here 32588, which is the original feature request which this pull request closes.
I had a similar misunderstanding. The If so, then the method you're looking for is If not, then what you're probably trying to do is expose the API to your scripts which run in the main world, e.g. you want to expose an API to the script tags in your html which you have loaded. If so, then use Hope this helps. |
Description of Change
This PR adds a new function, exposeInIsolatedWorld to contextBridge. With this change, custom APIs can be exposed to Isolated worlds without any hacks when
contextIsolation
is enabled.Fixes #32588
cc @miniak
Checklist
npm test
passesRelease Notes
Notes: Added
contextBridge.exposeInIsolatedWorld(worldId, key, api)
to expose an API to anisolatedWorld
within a renderer from a preload script.