From 1fe0d74840fef43d814087d3340965b3a0fca334 Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann Date: Mon, 7 Aug 2017 11:13:01 +0200 Subject: [PATCH] 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: https://github.com/nodejs/node/issues/12300 --- test/known_issues/test-vm-strict-mode.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/known_issues/test-vm-strict-mode.js diff --git a/test/known_issues/test-vm-strict-mode.js b/test/known_issues/test-vm-strict-mode.js new file mode 100644 index 00000000000000..3fc871e80d6893 --- /dev/null +++ b/test/known_issues/test-vm-strict-mode.js @@ -0,0 +1,17 @@ +'use strict'; +// https://github.com/nodejs/node/issues/12300 + +require('../common'); +const assert = require('assert'); +const vm = require('vm'); + +const ctx = vm.createContext({ x: 42 }); + +// The following line wrongly throws an +// error because GlobalPropertySetterCallback() +// does not check if the property exists +// on the sandbox. It should just set x to 1 +// instead of throwing an error. +vm.runInContext('"use strict"; x = 1', ctx); + +assert.strictEqual(ctx.x, 1);