mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
d2479fa020
Property enumerator methods like `Object.getOwnPropertyNames`, `Object.getOwnPropertySymbols`, and `Object.keys` all invokes the named property enumerator interceptor. V8 will filter the result based on the invoked enumerator variant. Fix the enumerator interceptor to return all potential properties. PR-URL: https://github.com/nodejs/node/pull/54522 Refs: https://github.com/jsdom/jsdom/issues/3688 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
27 lines
865 B
JavaScript
27 lines
865 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const vm = require('vm');
|
|
const assert = require('assert');
|
|
|
|
const sym1 = Symbol('1');
|
|
const sym2 = Symbol('2');
|
|
const sandbox = {
|
|
a: true,
|
|
[sym1]: true,
|
|
};
|
|
Object.defineProperty(sandbox, 'b', { value: true });
|
|
Object.defineProperty(sandbox, sym2, { value: true });
|
|
|
|
const ctx = vm.createContext(sandbox);
|
|
|
|
assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]);
|
|
assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']);
|
|
assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]);
|
|
|
|
const nativeKeys = vm.runInNewContext('Reflect.ownKeys(this);');
|
|
const ownKeys = vm.runInContext('Reflect.ownKeys(this);', ctx);
|
|
const restKeys = ownKeys.filter((key) => !nativeKeys.includes(key));
|
|
// This should not fail
|
|
assert.deepStrictEqual(Array.from(restKeys), ['a', 'b', sym1, sym2]);
|