Skip to content

Commit 1fe0d74

Browse files
committed
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`. Refs: nodejs#12300
1 parent daf5596 commit 1fe0d74

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)