-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Questions/clarifications about vm context behavior #19171
Comments
@nodejs/vm |
related heavily to #855, I'm actually working on a lot of this right now |
See #14660. I'd say that making these edge cases work in node-chakracore is not worth the effort, when we are not sure how |
There are other cases that are currently broken in node-chakracore and are less edge-case-ish, such as expecting that On that note, I see things like this: > var o = {}
undefined
> vm.createContext(o)
{}
> vm.runInContext('var NaN = 1', o)
undefined
> o
{}
> o.NaN
undefined
> vm.runInContext('var nan = 2', o)
undefined
> o
{ nan: 2 } so it looks like |
@MSLaguana We are explicitly ignoring those set operations. See Lines 338 to 346 in 78a7536
and surroundings. |
No further activity in over 2 years, closing |
Node-chakracore currently has different behavior to node built on v8 for
vm.runInContext
, and we'd like to try to fix that. However to do so we'd first like to get a solid understanding of exactly how it is supposed to work.My understanding is that
vm.runInContext(script, sandbox)
is supposed to run the given script as if the sandbox object were the global (but also have the normal global properties available). Any(?) changes made to the global object in that context are expected to be reflected back to the sandbox object, e.g. running “var x = 1” should cause the sandbox object to have an ‘x’ property with value 1, and “var y = this” should cause the sandbox object to have a ‘y’ property which references the sandbox object (not the global object in the context?). Is that both technically correct, and also the correct intuition for what thevm
module is for?If that’s right, then I have some follow up questions about the implementation as it stands today. I’m a little confused about how conflicts between properties are handled:
Why can we modify the non-shadowed property, but not the shadowed property? Is it because the global object’s
NaN
is non-writable, even though it is overridden by a writable property on the sandbox object?Why can we define a property on the sandbox, but not redefine a property? Is this because it is non-writable, even though it should be the configurability which applies here?
Is it intentional that references to the actual-global can escape from the vm context and behave almost-but-not-quite like the sandbox object?
Is it intentional that if configurability differs between the sandbox and a global property, that delete operates partially, while if both are configurable then delete will remove the property from both the sandbox and the global?
The text was updated successfully, but these errors were encountered: