-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the CopyProperties() hack in the vm module, i.e., Contextify. Use different V8 API methods, that allow interception of DefineProperty() and do not flatten accessor descriptors to property descriptors. Move many known issues to test cases. Factor out the last test in test-vm-context.js for #10223 into its own file, test-vm-strict-assign.js. Part of this CL is taken from a stalled PR by https://github.com/AnnaMag #13265 This PR requires a backport of https://chromium.googlesource.com/v8/v8/+/37a3a15c3e52e2146e45f41c427f24414e4d7f6f PR-URL: #16293 Fixes: #2734 Fixes: #10223 Fixes: #11803 Fixes: #11902 Ref: #6283 Ref: #15114 Ref: #13265 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
- Loading branch information
Showing
11 changed files
with
237 additions
and
195 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
test/known_issues/test-vm-attributes-property-not-on-sandbox.js
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
test/parallel/test-vm-attributes-property-not-on-sandbox.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
|
||
// Assert that accessor descriptors are not flattened on the sandbox. | ||
// Issue: https://github.com/nodejs/node/issues/2734 | ||
const sandbox = {}; | ||
vm.createContext(sandbox); | ||
const code = `Object.defineProperty( | ||
this, | ||
'foo', | ||
{ get: function() {return 17} } | ||
); | ||
var desc = Object.getOwnPropertyDescriptor(this, 'foo');`; | ||
|
||
vm.runInContext(code, sandbox); | ||
assert.strictEqual(typeof sandbox.desc.get, 'function'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
const vm = require('vm'); | ||
|
||
// https://github.com/nodejs/node/issues/10223 | ||
const ctx = vm.createContext(); | ||
|
||
// Define x with writable = false. | ||
vm.runInContext('Object.defineProperty(this, "x", { value: 42 })', ctx); | ||
assert.strictEqual(ctx.x, 42); | ||
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); |
This file was deleted.
Oops, something went wrong.