xref: /third_party/node/test/known_issues/test-vm-function-declaration-uses-define.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/known_issues/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// https://github.com/nodejs/node/issues/31808
41cb0ef41Sopenharmony_ci// function declarations currently call [[Set]] instead of [[DefineOwnProperty]]
51cb0ef41Sopenharmony_ci// in VM contexts, which violates the ECMA-262 specification:
61cb0ef41Sopenharmony_ci// https://tc39.es/ecma262/#sec-createglobalfunctionbinding
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst common = require('../common');
91cb0ef41Sopenharmony_ciconst vm = require('vm');
101cb0ef41Sopenharmony_ciconst assert = require('assert');
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst ctx = vm.createContext();
131cb0ef41Sopenharmony_ciObject.defineProperty(ctx, 'x', {
141cb0ef41Sopenharmony_ci  enumerable: true,
151cb0ef41Sopenharmony_ci  configurable: true,
161cb0ef41Sopenharmony_ci  get: common.mustNotCall('ctx.x getter must not be called'),
171cb0ef41Sopenharmony_ci  set: common.mustNotCall('ctx.x setter must not be called'),
181cb0ef41Sopenharmony_ci});
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_civm.runInContext('function x() {}', ctx);
211cb0ef41Sopenharmony_ciassert.strictEqual(typeof ctx.x, 'function');
22

Indexes created Thu Nov 07 10:32:03 CST 2024