mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
vm: add tests for function declarations using [[DefineOwnProperty]]
Refs: https://github.com/nodejs/node/issues/31808 PR-URL: https://github.com/nodejs/node/pull/34032 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host>
This commit is contained in:
parent
7b29c91944
commit
7f51e79511
|
|
@ -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');
|
||||
Loading…
Reference in New Issue
Block a user