Skip to content

Commit c9b652f

Browse files
ExE-BossMylesBorins
authored andcommitted
vm: add tests for function declarations using [[DefineOwnProperty]]
Refs: #31808 PR-URL: #34032 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gus Caplan <[email protected]>
1 parent f60e58b commit c9b652f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
// https://github.com/nodejs/node/issues/31808
4+
// function declarations currently call [[Set]] instead of [[DefineOwnProperty]]
5+
// in VM contexts, which violates the ECMA-262 specification:
6+
// https://tc39.es/ecma262/#sec-createglobalfunctionbinding
7+
8+
const common = require('../common');
9+
const vm = require('vm');
10+
const assert = require('assert');
11+
12+
const ctx = vm.createContext();
13+
Object.defineProperty(ctx, 'x', {
14+
enumerable: true,
15+
configurable: true,
16+
get: common.mustNotCall('ctx.x getter must not be called'),
17+
set: common.mustNotCall('ctx.x setter must not be called'),
18+
});
19+
20+
vm.runInContext('function x() {}', ctx);
21+
assert.strictEqual(typeof ctx.x, 'function');

0 commit comments

Comments
 (0)