forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vm: add tests for function declarations using [[DefineOwnProperty]]
Refs: nodejs#31808
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
test/known_issues/test-vm-function-declaration-uses-define.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |