11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cirequire('../common');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst vm = require('vm');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cilet base = {
91cb0ef41Sopenharmony_ci  propBase: 1
101cb0ef41Sopenharmony_ci};
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cilet sandbox = Object.create(base, {
131cb0ef41Sopenharmony_ci  propSandbox: { value: 3 }
141cb0ef41Sopenharmony_ci});
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciconst context = vm.createContext(sandbox);
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_cilet result = vm.runInContext('Object.hasOwnProperty(this, "propBase");',
191cb0ef41Sopenharmony_ci                             context);
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ciassert.strictEqual(result, false);
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci// Ref: https://github.com/nodejs/node/issues/5350
241cb0ef41Sopenharmony_cibase = Object.create(null);
251cb0ef41Sopenharmony_cibase.x = 1;
261cb0ef41Sopenharmony_cibase.y = 2;
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_cisandbox = Object.create(base);
291cb0ef41Sopenharmony_cisandbox.z = 3;
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ciassert.deepStrictEqual(Object.keys(sandbox), ['z']);
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ciconst code = 'x = 0; z = 4;';
341cb0ef41Sopenharmony_ciresult = vm.runInNewContext(code, sandbox);
351cb0ef41Sopenharmony_ciassert.strictEqual(result, 4);
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci// Check that y is not an own property.
381cb0ef41Sopenharmony_ciassert.deepStrictEqual(Object.keys(sandbox), ['z', 'x']);
39