11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci// Refs: https://github.com/nodejs/node/issues/2734 31cb0ef41Sopenharmony_cirequire('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst vm = require('vm'); 61cb0ef41Sopenharmony_ciconst sandbox = {}; 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciObject.defineProperty(sandbox, 'prop', { 91cb0ef41Sopenharmony_ci get() { 101cb0ef41Sopenharmony_ci return 'foo'; 111cb0ef41Sopenharmony_ci } 121cb0ef41Sopenharmony_ci}); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst descriptor = Object.getOwnPropertyDescriptor(sandbox, 'prop'); 151cb0ef41Sopenharmony_ciconst context = vm.createContext(sandbox); 161cb0ef41Sopenharmony_ciconst code = 'Object.getOwnPropertyDescriptor(this, "prop");'; 171cb0ef41Sopenharmony_ciconst result = vm.runInContext(code, context); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci// Ref: https://github.com/nodejs/node/issues/11803 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciassert.deepStrictEqual(Object.keys(result), Object.keys(descriptor)); 221cb0ef41Sopenharmony_cifor (const prop of Object.keys(result)) { 231cb0ef41Sopenharmony_ci assert.strictEqual(result[prop], descriptor[prop]); 241cb0ef41Sopenharmony_ci} 25