mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
f1d6b04ac9
Remove the CopyProperties() hack in the vm module, i.e., Contextify.
Use different V8 API methods, that allow interception of
DefineProperty() and do not flatten accessor descriptors to
property descriptors.
Move many known issues to test cases. Factor out the last test in
test-vm-context.js for
https://github.com/nodejs/node/issues/10223
into its own file, test-vm-strict-assign.js.
Part of this CL is taken from a stalled PR by
https://github.com/AnnaMag
https://github.com/nodejs/node/pull/13265
This PR requires a backport of
37a3a15c3e
PR-URL: https://github.com/nodejs/node/pull/16293
Fixes: https://github.com/nodejs/node/issues/2734
Fixes: https://github.com/nodejs/node/issues/10223
Fixes: https://github.com/nodejs/node/issues/11803
Fixes: https://github.com/nodejs/node/issues/11902
Ref: https://github.com/nodejs/node/issues/6283
Ref: https://github.com/nodejs/node/pull/15114
Ref: https://github.com/nodejs/node/pull/13265
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
29 lines
653 B
JavaScript
29 lines
653 B
JavaScript
'use strict';
|
|
// Refs: https://github.com/nodejs/node/issues/10223
|
|
|
|
require('../common');
|
|
const vm = require('vm');
|
|
const assert = require('assert');
|
|
|
|
const context = vm.createContext({});
|
|
|
|
let code = `
|
|
Object.defineProperty(this, 'foo', {value: 5});
|
|
Object.getOwnPropertyDescriptor(this, 'foo');
|
|
`;
|
|
|
|
let desc = vm.runInContext(code, context);
|
|
|
|
assert.strictEqual(desc.writable, false);
|
|
|
|
// Check that interceptors work for symbols.
|
|
code = `
|
|
const bar = Symbol('bar');
|
|
Object.defineProperty(this, bar, {value: 6});
|
|
Object.getOwnPropertyDescriptor(this, bar);
|
|
`;
|
|
|
|
desc = vm.runInContext(code, context);
|
|
|
|
assert.strictEqual(desc.value, 6);
|