Skip to content

Commit

Permalink
vm: add tests for function declarations using [[DefineOwnProperty]]
Browse files Browse the repository at this point in the history
Refs: #31808

PR-URL: #34032
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
  • Loading branch information
ExE-Boss authored and MylesBorins committed Jul 27, 2020
1 parent f60e58b commit c9b652f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/known_issues/test-vm-function-declaration-uses-define.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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');

0 comments on commit c9b652f

Please sign in to comment.