From c9b652f13f1b29afc2e2864e5ff725cd2dbb64fc Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Tue, 23 Jun 2020 18:00:00 +0200 Subject: [PATCH] =?UTF-8?q?vm:=20add=C2=A0tests=20for=C2=A0function=C2=A0d?= =?UTF-8?q?eclarations=20using=C2=A0[[DefineOwnProperty]]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/issues/31808 PR-URL: https://github.com/nodejs/node/pull/34032 Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan --- ...est-vm-function-declaration-uses-define.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/known_issues/test-vm-function-declaration-uses-define.js diff --git a/test/known_issues/test-vm-function-declaration-uses-define.js b/test/known_issues/test-vm-function-declaration-uses-define.js new file mode 100644 index 00000000000000..1cfdd9c368e570 --- /dev/null +++ b/test/known_issues/test-vm-function-declaration-uses-define.js @@ -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');