11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_cirequire('../common'); 41cb0ef41Sopenharmony_ciconst vm = require('vm'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst sym1 = Symbol('1'); 81cb0ef41Sopenharmony_ciconst sym2 = Symbol('2'); 91cb0ef41Sopenharmony_ciconst sandbox = { 101cb0ef41Sopenharmony_ci a: true, 111cb0ef41Sopenharmony_ci [sym1]: true, 121cb0ef41Sopenharmony_ci}; 131cb0ef41Sopenharmony_ciObject.defineProperty(sandbox, 'b', { value: true }); 141cb0ef41Sopenharmony_ciObject.defineProperty(sandbox, sym2, { value: true }); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst ctx = vm.createContext(sandbox); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci// Sanity check 191cb0ef41Sopenharmony_ci// Please uncomment these when the test is no longer broken 201cb0ef41Sopenharmony_ci// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]); 211cb0ef41Sopenharmony_ci// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']); 221cb0ef41Sopenharmony_ci// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciconst nativeNames = vm.runInNewContext('Object.getOwnPropertyNames(this);'); 251cb0ef41Sopenharmony_ciconst ownNames = vm.runInContext('Object.getOwnPropertyNames(this);', ctx); 261cb0ef41Sopenharmony_ciconst restNames = ownNames.filter((name) => !nativeNames.includes(name)); 271cb0ef41Sopenharmony_ci// This should not fail 281cb0ef41Sopenharmony_ciassert.deepStrictEqual(Array.from(restNames), ['a', 'b']); 29