Skip to content

Commit 1e231ba

Browse files
fhinkelMylesBorins
authored andcommitted
test: add known issue for vm module
GlobalPropertySetterCallback() does not check the property on the sandbox. It wrongly throws an error instead of updating `x`. PR-URL: #14661 Ref: #12300 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
1 parent 644d990 commit 1e231ba

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
// https://github.com/nodejs/node/issues/12300
3+
4+
require('../common');
5+
const assert = require('assert');
6+
const vm = require('vm');
7+
8+
const ctx = vm.createContext({ x: 42 });
9+
10+
// The following line wrongly throws an
11+
// error because GlobalPropertySetterCallback()
12+
// does not check if the property exists
13+
// on the sandbox. It should just set x to 1
14+
// instead of throwing an error.
15+
vm.runInContext('"use strict"; x = 1', ctx);
16+
17+
assert.strictEqual(ctx.x, 1);

0 commit comments

Comments
 (0)