Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 74ff804

Browse filesBrowse files
addaleaxItalo A. Casas
authored andcommitted
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 <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 8a6367c commit 74ff804
Copy full SHA for 74ff804

File tree

Expand file treeCollapse file tree

2 files changed

+31
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+31
-0
lines changed
Open diff view settings
Collapse file
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
// https://github.com/nodejs/node/issues/10223
3+
4+
require('../common');
5+
const assert = require('assert');
6+
const vm = require('vm');
7+
8+
const ctx = vm.createContext();
9+
vm.runInContext('Object.defineProperty(this, "x", { value: 42 })', ctx);
10+
assert.strictEqual(ctx.x, undefined); // Not copied out by cloneProperty().
11+
assert.strictEqual(vm.runInContext('x', ctx), 42);
12+
vm.runInContext('x = 0', ctx); // Does not throw but x...
13+
assert.strictEqual(vm.runInContext('x', ctx), 42); // ...should be unaltered.
14+
assert.throws(() => vm.runInContext('"use strict"; x = 0', ctx),
15+
/Cannot assign to read only property 'x'/);
16+
assert.strictEqual(vm.runInContext('x', ctx), 42);
Collapse file
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
// Regression test for https://github.com/nodejs/node/issues/10806
3+
4+
require('../common');
5+
const assert = require('assert');
6+
const vm = require('vm');
7+
const ctx = vm.createContext({ open() { } });
8+
const window = vm.runInContext('this', ctx);
9+
const other = 123;
10+
11+
assert.notStrictEqual(window.open, other);
12+
window.open = other;
13+
assert.strictEqual(window.open, other);
14+
window.open = other;
15+
assert.strictEqual(window.open, other);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.