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 <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
1 parent 644d990 commit 1e231ba

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
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)