-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: fix vm bug for configurable globalThis
Object.defineProperty allows to change the value for non-writable properties if they are configurable. We missed that case when checking if a property is read-only. Fixes: #47799 PR-URL: #51602 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
- Loading branch information
Showing
2 changed files
with
21 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
// https://github.com/nodejs/node/issues/47799 | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const vm = require('vm'); | ||
|
||
const ctx = vm.createContext(); | ||
|
||
const window = vm.runInContext('this', ctx); | ||
|
||
Object.defineProperty(window, 'x', { value: '1', configurable: true }); | ||
assert.strictEqual(window.x, '1'); | ||
Object.defineProperty(window, 'x', { value: '2', configurable: true }); | ||
assert.strictEqual(window.x, '2'); |