forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vm: fix property descriptors of sandbox properties
The GlobalPropertyQueryCallback was changed in 2010 to return an integer instead of a boolean: https://groups.google.com/forum/#!topic/v8-users/OOjHJrix-cU This integer communicates the property descriptors of the property, instead of just its presence or absence. However, the original contextify code was probably written before this change, and it was not updated when porting to Node.js. Credit to @smikes for the test and the original PR of nodejs#885. Fixes nodejs#885; fixes nodejs#864.
- Loading branch information
Showing
2 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
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,24 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
|
||
var vm = require('vm'); | ||
|
||
var code = 'Object.getOwnPropertyDescriptor(this, "prop")'; | ||
|
||
var x = {}; | ||
Object.defineProperty(x, "prop", { | ||
configurable: false, | ||
enumerable: false, | ||
writable: false, | ||
value: "val" | ||
}); | ||
var o = vm.createContext(x); | ||
|
||
var res = vm.runInContext(code, o, 'test'); | ||
|
||
assert(res); | ||
assert.equal(typeof res, 'object'); | ||
assert.equal(res.value, "val"); | ||
assert.equal(res.configurable, false, "should not be configurable"); | ||
assert.equal(res.enumerable, false, "should not be enumerable"); | ||
assert.equal(res.writable, false, "should not be writable"); |