-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add failing vm tests to known_issues
Currently, `Reflect.ownKeys(this)`, `Object.getOwnPropertyNames(this)` and `Object.getOwnPropertySymbols(this)` when run in a sandbox, fails to retrieve Symbol and non-enumerable values. PR-URL: #16410 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'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); | ||
|
||
// Sanity check | ||
// Please uncomment these when the test is no longer broken | ||
// 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]); |
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,28 @@ | ||
'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); | ||
|
||
// Sanity check | ||
// Please uncomment these when the test is no longer broken | ||
// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]); | ||
// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']); | ||
// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]); | ||
|
||
const nativeNames = vm.runInNewContext('Object.getOwnPropertyNames(this);'); | ||
const ownNames = vm.runInContext('Object.getOwnPropertyNames(this);', ctx); | ||
const restNames = ownNames.filter((name) => !nativeNames.includes(name)); | ||
// this should not fail | ||
assert.deepStrictEqual(Array.from(restNames), ['a', 'b']); |
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,28 @@ | ||
'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); | ||
|
||
// Sanity check | ||
// Please uncomment these when the test is no longer broken | ||
// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]); | ||
// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']); | ||
// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]); | ||
|
||
const nativeSym = vm.runInNewContext('Object.getOwnPropertySymbols(this);'); | ||
const ownSym = vm.runInContext('Object.getOwnPropertySymbols(this);', ctx); | ||
const restSym = ownSym.filter((sym) => !nativeSym.includes(sym)); | ||
// this should not fail | ||
assert.deepStrictEqual(Array.from(restSym), [sym1, sym2]); |