summaryrefslogtreecommitdiff
path: root/test/known_issues/test-vm-function-declaration-uses-define.js
blob: 1cfdd9c368e570ac0d6a594db356d5ebd3c5a061 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';

// https://github.com/nodejs/node/issues/31808
// function declarations currently call [[Set]] instead of [[DefineOwnProperty]]
// in VM contexts, which violates the ECMA-262 specification:
// https://tc39.es/ecma262/#sec-createglobalfunctionbinding

const common = require('../common');
const vm = require('vm');
const assert = require('assert');

const ctx = vm.createContext();
Object.defineProperty(ctx, 'x', {
  enumerable: true,
  configurable: true,
  get: common.mustNotCall('ctx.x getter must not be called'),
  set: common.mustNotCall('ctx.x setter must not be called'),
});

vm.runInContext('function x() {}', ctx);
assert.strictEqual(typeof ctx.x, 'function');