Created
January 14, 2017 17:22
-
-
Save AnnaMag/bc5201b057e03203f57210e7c7ec278d to your computer and use it in GitHub Desktop.
test vm 3
This file contains hidden or 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
'use strict'; | |
// Refs: https://github.com/nodejs/node/issues/2734 | |
require('../common'); | |
const assert = require('assert'); | |
const vm = require('vm'); | |
const util = require('util'); | |
const sandbox = { globalVar: 1, v: 12 }; | |
Object.defineProperty(sandbox, 'prop', { | |
get() { | |
return 'foo'; | |
} | |
}); | |
const descriptor = Object.getOwnPropertyDescriptor(sandbox, 'prop'); | |
const context = vm.createContext(sandbox); | |
const code = 'Object.getOwnPropertyDescriptor(this, "prop");'; | |
var result = vm.runInContext(code, context); | |
console.log(util.inspect(sandbox)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment