| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8a6367c commit 74ff804
2 files changed
| Original file line number | Diff line number | Diff 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); | ||
| Original file line number | Diff line number | Diff 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); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments