From 34d1a779b132f6dbc104ff4fff5c5fe482a324dd 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GlobalPropertySetterCallback() does not check the property on the sandbox. It wrongly throws an error instead of updating `x`. PR-URL: https://github.com/nodejs/node/pull/14661 Ref: https://github.com/nodejs/node/issues/12300 Reviewed-By: Ben Noordhuis Reviewed-By: Tobias Nießen Reviewed-By: Colin Ihrig Reviewed-By: Refael Ackermann Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Yuta Hiroto Reviewed-By: Timothy Gu --- 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..9528944732930c --- /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);