Sha256: 735d17d0cd53bad796b2c2878022ddf7db27ce64fb79094e64d922a058b3d681
Contents?: true
Size: 980 Bytes
Versions: 5
Compression:
Stored size: 980 Bytes
Contents
'use strict'; require('../common'); var assert = require('assert'); var vm = require('vm'); // src/node_contextify.cc filters out the Proxy object from the parent // context. Make sure that the new context has a Proxy object of its own. var sandbox = {}; vm.runInNewContext('this.Proxy = Proxy', sandbox); assert.strictEqual(typeof sandbox.Proxy, 'function'); assert.notStrictEqual(sandbox.Proxy, Proxy); // Unless we copy the Proxy object explicitly, of course. sandbox = { Proxy: Proxy }; vm.runInNewContext('this.Proxy = Proxy', sandbox); assert.strictEqual(typeof sandbox.Proxy, 'function'); assert.strictEqual(sandbox.Proxy, Proxy); // Handle a sandbox that throws while copying properties assert.throws(() => { const handler = { getOwnPropertyDescriptor: (target, prop) => { throw new Error('whoops'); } }; const sandbox = new Proxy({foo: 'bar'}, handler); const context = vm.createContext(sandbox); vm.runInContext('', context); }, /whoops/);
Version data entries
5 entries across 4 versions & 1 rubygems