-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Revert "src: don't overwrite non-writable vm globals" #10920
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
// https://github.com/nodejs/node/issues/10223 | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
|
||
const ctx = vm.createContext(); | ||
vm.runInContext('Object.defineProperty(this, "x", { value: 42 })', ctx); | ||
assert.strictEqual(ctx.x, undefined); // Not copied out by cloneProperty(). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For future reference: it's not IMO the expected or desired behavior, just the actual behavior. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bnoordhuis Right, I agree. Would you prefer it if I updated the test with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need, it was more of an off-the-cuff remark. |
||
assert.strictEqual(vm.runInContext('x', ctx), 42); | ||
vm.runInContext('x = 0', ctx); // Does not throw but x... | ||
assert.strictEqual(vm.runInContext('x', ctx), 42); // ...should be unaltered. | ||
assert.throws(() => vm.runInContext('"use strict"; x = 0', ctx), | ||
/Cannot assign to read only property 'x'/); | ||
assert.strictEqual(vm.runInContext('x', ctx), 42); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
// Regression test for https://github.com/nodejs/node/issues/10806 | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
const ctx = vm.createContext({ open() { } }); | ||
const window = vm.runInContext('this', ctx); | ||
const other = 123; | ||
|
||
assert.notStrictEqual(window.open, other); | ||
window.open = other; | ||
assert.strictEqual(window.open, other); | ||
window.open = other; | ||
assert.strictEqual(window.open, other); |
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.
We came to the conclusion that is_contextual_store is always true and shouldn't be here in the first place. Do you want to remove it from the revert or should I make an extra PR. Extra PR probably keeps history and bisects cleaner.
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.
Yeah, an extra PR sounds better – mostly because
a) this PR can be landed now (if anybody reading this has a few minutes left over, please feel free to take that task) and
b) because my understanding of this code is actually kind of limited ;)