Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 977fe22

Browse filesBrowse 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
Copy full SHA for 977fe22

File tree

Expand file treeCollapse file tree

3 files changed

+84
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+84
-0
lines changed
Open diff view settings
Collapse file
+28Lines 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+
const vm = require('vm');
5+
const assert = require('assert');
6+
7+
const sym1 = Symbol('1');
8+
const sym2 = Symbol('2');
9+
const sandbox = {
10+
a: true,
11+
[sym1]: true
12+
};
13+
Object.defineProperty(sandbox, 'b', { value: true });
14+
Object.defineProperty(sandbox, sym2, { value: true });
15+
16+
const ctx = 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+
const nativeKeys = vm.runInNewContext('Reflect.ownKeys(this);');
25+
const ownKeys = vm.runInContext('Reflect.ownKeys(this);', ctx);
26+
const restKeys = ownKeys.filter((key) => !nativeKeys.includes(key));
27+
// this should not fail
28+
assert.deepStrictEqual(Array.from(restKeys), ['a', 'b', sym1, sym2]);
Collapse file
+28Lines 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+
const vm = require('vm');
5+
const assert = require('assert');
6+
7+
const sym1 = Symbol('1');
8+
const sym2 = Symbol('2');
9+
const sandbox = {
10+
a: true,
11+
[sym1]: true
12+
};
13+
Object.defineProperty(sandbox, 'b', { value: true });
14+
Object.defineProperty(sandbox, sym2, { value: true });
15+
16+
const ctx = 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+
const nativeNames = vm.runInNewContext('Object.getOwnPropertyNames(this);');
25+
const ownNames = vm.runInContext('Object.getOwnPropertyNames(this);', ctx);
26+
const restNames = ownNames.filter((name) => !nativeNames.includes(name));
27+
// this should not fail
28+
assert.deepStrictEqual(Array.from(restNames), ['a', 'b']);
Collapse file
+28Lines 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+
const vm = require('vm');
5+
const assert = require('assert');
6+
7+
const sym1 = Symbol('1');
8+
const sym2 = Symbol('2');
9+
const sandbox = {
10+
a: true,
11+
[sym1]: true
12+
};
13+
Object.defineProperty(sandbox, 'b', { value: true });
14+
Object.defineProperty(sandbox, sym2, { value: true });
15+
16+
const ctx = 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+
const nativeSym = vm.runInNewContext('Object.getOwnPropertySymbols(this);');
25+
const ownSym = vm.runInContext('Object.getOwnPropertySymbols(this);', ctx);
26+
const restSym = ownSym.filter((sym) => !nativeSym.includes(sym));
27+
// this should not fail
28+
assert.deepStrictEqual(Array.from(restSym), [sym1, sym2]);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.