Skip to content

Commit 977fe22

Browse files
targosgibfahn
authored andcommitted
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>
1 parent 0a5a2c4 commit 977fe22

3 files changed

Lines changed: 84 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
require('../common');
4+
constvm=require('vm');
5+
constassert=require('assert');
6+
7+
constsym1=Symbol('1');
8+
constsym2=Symbol('2');
9+
constsandbox={
10+
a: true,
11+
[sym1]: true
12+
};
13+
Object.defineProperty(sandbox,'b',{value: true});
14+
Object.defineProperty(sandbox,sym2,{value: true});
15+
16+
constctx=vm.createContext(sandbox);
17+
18+
// Sanity check
19+
// Please uncomment these when the test is no longer broken
20+
// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]);
21+
// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']);
22+
// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]);
23+
24+
constnativeKeys=vm.runInNewContext('Reflect.ownKeys(this);');
25+
constownKeys=vm.runInContext('Reflect.ownKeys(this);',ctx);
26+
constrestKeys=ownKeys.filter((key)=>!nativeKeys.includes(key));
27+
// this should not fail
28+
assert.deepStrictEqual(Array.from(restKeys),['a','b',sym1,sym2]);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
require('../common');
4+
constvm=require('vm');
5+
constassert=require('assert');
6+
7+
constsym1=Symbol('1');
8+
constsym2=Symbol('2');
9+
constsandbox={
10+
a: true,
11+
[sym1]: true
12+
};
13+
Object.defineProperty(sandbox,'b',{value: true});
14+
Object.defineProperty(sandbox,sym2,{value: true});
15+
16+
constctx=vm.createContext(sandbox);
17+
18+
// Sanity check
19+
// Please uncomment these when the test is no longer broken
20+
// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]);
21+
// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']);
22+
// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]);
23+
24+
constnativeNames=vm.runInNewContext('Object.getOwnPropertyNames(this);');
25+
constownNames=vm.runInContext('Object.getOwnPropertyNames(this);',ctx);
26+
constrestNames=ownNames.filter((name)=>!nativeNames.includes(name));
27+
// this should not fail
28+
assert.deepStrictEqual(Array.from(restNames),['a','b']);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
require('../common');
4+
constvm=require('vm');
5+
constassert=require('assert');
6+
7+
constsym1=Symbol('1');
8+
constsym2=Symbol('2');
9+
constsandbox={
10+
a: true,
11+
[sym1]: true
12+
};
13+
Object.defineProperty(sandbox,'b',{value: true});
14+
Object.defineProperty(sandbox,sym2,{value: true});
15+
16+
constctx=vm.createContext(sandbox);
17+
18+
// Sanity check
19+
// Please uncomment these when the test is no longer broken
20+
// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]);
21+
// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']);
22+
// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]);
23+
24+
constnativeSym=vm.runInNewContext('Object.getOwnPropertySymbols(this);');
25+
constownSym=vm.runInContext('Object.getOwnPropertySymbols(this);',ctx);
26+
constrestSym=ownSym.filter((sym)=>!nativeSym.includes(sym));
27+
// this should not fail
28+
assert.deepStrictEqual(Array.from(restSym),[sym1,sym2]);

0 commit comments

Comments
 (0)