mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
5856c836ea
This patch fixes the problem with variables that are declared only on the sandbox but not on the global proxy. PR-URL: https://github.com/nodejs/node/pull/16487 Fixes: https://github.com/nodejs/node/issues/12300 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
15 lines
385 B
JavaScript
15 lines
385 B
JavaScript
'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 });
|
|
|
|
// This might look as if x has not been declared, but x is defined on the
|
|
// sandbox and the assignment should not throw.
|
|
vm.runInContext('"use strict"; x = 1', ctx);
|
|
|
|
assert.strictEqual(ctx.x, 1);
|