This repository has been archived by the owner on Aug 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
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 nodejs/node#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 nodejs/node#13265 This PR requires a backport of https://chromium.googlesource.com/v8/v8/+/37a3a15c3e52e2146e45f41c427f24414e4d7f6f PR-URL: nodejs/node#16293 Fixes: nodejs/node#2734 Fixes: nodejs/node#10223 Fixes: nodejs/node#11803 Fixes: nodejs/node#11902 Ref: nodejs/node#6283 Ref: nodejs/node#15114 Ref: nodejs/node#13265 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
- 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.