1'use strict'; 2 3require('../common'); 4const vm = require('vm'); 5const assert = require('assert'); 6 7const sym1 = Symbol('1'); 8const sym2 = Symbol('2'); 9const sandbox = { 10 a: true, 11 [sym1]: true 12}; 13Object.defineProperty(sandbox, 'b', { value: true }); 14Object.defineProperty(sandbox, sym2, { value: true }); 15 16const ctx = vm.createContext(sandbox); 17 18// Sanity check 19// Please uncomment these when the test is no longer broken 20// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]); 21// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']); 22// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]); 23 24const nativeNames = vm.runInNewContext('Object.getOwnPropertyNames(this);'); 25const ownNames = vm.runInContext('Object.getOwnPropertyNames(this);', ctx); 26const restNames = ownNames.filter((name) => !nativeNames.includes(name)); 27// This should not fail 28assert.deepStrictEqual(Array.from(restNames), ['a', 'b']); 29