-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add regression tests for vm bugs
Add the regression test script presented in #10806 to `test/parallel` and re-add the original regression test for #10223 in `test/known_issues`. PR-URL: #10920 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
- Loading branch information
1 parent
8a6367c
commit 74ff804
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
test/known_issues/test-vm-global-non-writable-properties.js
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,16 @@ | ||
'use strict'; | ||
// https://github.com/nodejs/node/issues/10223 | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
|
||
const ctx = vm.createContext(); | ||
vm.runInContext('Object.defineProperty(this, "x", { value: 42 })', ctx); | ||
assert.strictEqual(ctx.x, undefined); // Not copied out by cloneProperty(). | ||
assert.strictEqual(vm.runInContext('x', ctx), 42); | ||
vm.runInContext('x = 0', ctx); // Does not throw but x... | ||
assert.strictEqual(vm.runInContext('x', ctx), 42); // ...should be unaltered. | ||
assert.throws(() => vm.runInContext('"use strict"; x = 0', ctx), | ||
/Cannot assign to read only property 'x'/); | ||
assert.strictEqual(vm.runInContext('x', ctx), 42); |
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,15 @@ | ||
'use strict'; | ||
// Regression test for https://github.com/nodejs/node/issues/10806 | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
const ctx = vm.createContext({ open() { } }); | ||
const window = vm.runInContext('this', ctx); | ||
const other = 123; | ||
|
||
assert.notStrictEqual(window.open, other); | ||
window.open = other; | ||
assert.strictEqual(window.open, other); | ||
window.open = other; | ||
assert.strictEqual(window.open, other); |