forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The interceptor should not copy a value onto the sandbox, if setting on
the global object will fail because we are in strict mode. Function declarations should not throw, we expect that they are not set when we define them, so copy them over! Add test for setting variable in strict mode for issue nodejs#5344.
- Loading branch information
Showing
4 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// https://github.com/nodejs/node/issues/5344 | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
const ctx = vm.createContext(); | ||
|
||
vm.runInContext('w = 1;', ctx); | ||
assert.equal(1, ctx.w); | ||
|
||
assert.throws(function() {vm.runInContext('"use strict"; x = 1;', ctx);}); | ||
assert.equal(undefined, ctx.x); | ||
|
||
vm.runInContext('"use strict"; var y = 1;', ctx); | ||
assert.equal(1, ctx.y); | ||
|
||
vm.runInContext('"use strict"; this.z = 1;', ctx); | ||
assert.equal(1, ctx.z); | ||
|
||
// w has been defined | ||
vm.runInContext('"use strict"; w = 2;', ctx); | ||
assert.equal(2, ctx.w); |