-
Notifications
You must be signed in to change notification settings - Fork 16.2k
feat: add ContextBridgeMutability feature #27348
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 ContextBridgeMutability feature #27348
Conversation
p.s. - haven't wrote any tests for this, but happy to do it if someone explains me how to do something like |
You should be able to do exactly that. |
Can you be more concrete please? Calling |
You can start a new Electron app and read its output, for example: |
e487796
to
7409330
Compare
done |
bbb5a47
to
b105042
Compare
b105042
to
dc55919
Compare
What's the reasoning for this? It seems questionably useful to me. |
For the case when you're modifying exposed values in a existing codebase and don't wanna refactor it when you enable context isolation. |
@nornagon does the reason I posted makes sense to you? we've used this functionality in our electron fork, but I'm ok with abandoning this PR if you don't wanna merge it |
Hm, I'm skeptical that this is broadly useful. It's possible to replicate this behavior with a Proxy, which I think is more flexible and clearer (it's surprising, i think, that any modifications aren't reflected back to the isolated world). I'm OK to merge this behind the flag as it's quite a small change and well-tested, but I don't think this should ever be "sanctioned" behavior. |
why? objects in isolated and main worlds are completely different objects let's merge it then |
@nikitakot that follows if you're familiar with the implementation details of contextBridge, but for a naive user I think it's surprising, because in other ways contextBridge seems "seamless", and feels like a regular JS object. |
Release Notes Persisted
|
Description of Change
This PR adds a new
base::Feature
-ContextBridgeMutability
. When the feature is enabled values that are exposed via context bridge are not freezed and are not made readonly.ContextBridgeMutability off

ContextBridgeMutability on

As discussed with @MarshallOfSound no need to document it.
Checklist
npm test
passesRelease Notes
Notes: Adding
ContextBridgeMutability
feature that skips context bridgeDeepFreeze
andSetReadOnlyNonConfigurable
when exposing a value.