forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some of the choices here are odd, including that symbols are missing. However, that matches previous behaviour. What had to be changed was that inherited properties are no longer included; the alternative would be to also refactor the descriptor callbacks to provide data for inherited properties. Fixes: nodejs#22723 Refs: nodejs#22390
- Loading branch information
Showing
4 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
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
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
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,45 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
|
||
// Regression test for https://github.com/nodejs/node/issues/22723. | ||
|
||
const kFoo = Symbol('kFoo'); | ||
|
||
const test = { | ||
'not': 'empty', | ||
'0': 0, | ||
'0.5': 0.5, | ||
'1': 1, | ||
'-1': -1, | ||
[kFoo]: kFoo | ||
}; | ||
vm.createContext(test); | ||
const proxied = vm.runInContext('this', test); | ||
|
||
// TODO(addaleax): The .sort() calls should not be necessary; the property | ||
// order should be indices, then other properties, then symbols. | ||
assert.deepStrictEqual( | ||
Object.keys(proxied).sort(), | ||
['0', '1', 'not', '0.5', '-1'].sort()); | ||
assert.deepStrictEqual( | ||
// Filter out names shared by all global objects, i.e. JS builtins. | ||
Object.getOwnPropertyNames(proxied) | ||
.filter((name) => !(name in global)) | ||
.sort(), | ||
['0', '1', 'not', '0.5', '-1'].sort()); | ||
assert.deepStrictEqual(Object.getOwnPropertySymbols(proxied), []); | ||
|
||
Object.setPrototypeOf(test, { inherited: 'true', 17: 42 }); | ||
|
||
assert.deepStrictEqual( | ||
Object.keys(proxied).sort(), | ||
['0', '1', 'not', '0.5', '-1'].sort()); | ||
assert.deepStrictEqual( | ||
// Filter out names shared by all global objects, i.e. JS builtins. | ||
Object.getOwnPropertyNames(proxied) | ||
.filter((name) => !(name in global)) | ||
.sort(), | ||
['0', '1', 'not', '0.5', '-1'].sort()); | ||
assert.deepStrictEqual(Object.getOwnPropertySymbols(proxied), []); |
File renamed without changes.