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 nativeKeys = vm.runInNewContext('Reflect.ownKeys(this);'); 25const ownKeys = vm.runInContext('Reflect.ownKeys(this);', ctx); 26const restKeys = ownKeys.filter((key) => !nativeKeys.includes(key)); 27// This should not fail 28assert.deepStrictEqual(Array.from(restKeys), ['a', 'b', sym1, sym2]); 29