diff options
author | Michaƫl Zasso <targos@protonmail.com> | 2022-05-07 01:32:42 +0300 |
---|---|---|
committer | RafaelGSS <rafael.nunu@hotmail.com> | 2022-05-10 15:13:19 +0300 |
commit | 38e4c1553407ba0317cc0c640535dc9cdec9410d (patch) | |
tree | 44b663d345d826cd34e1b0b888b60e697d4444c3 /test/parallel/test-vm-global-setter.js | |
parent | 5470578008023f426f0ace07a192c81256c889d9 (diff) |
src: always signal V8 for intercepted properties
Closes: https://github.com/nodejs/node/issues/42962
PR-URL: https://github.com/nodejs/node/pull/42963
Fixes: https://github.com/nodejs/node/issues/42962
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'test/parallel/test-vm-global-setter.js')
-rw-r--r-- | test/parallel/test-vm-global-setter.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/parallel/test-vm-global-setter.js b/test/parallel/test-vm-global-setter.js new file mode 100644 index 00000000000..878937f612a --- /dev/null +++ b/test/parallel/test-vm-global-setter.js @@ -0,0 +1,32 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const vm = require('vm'); + +const window = createWindow(); + +const descriptor = + Object.getOwnPropertyDescriptor(window.globalProxy, 'onhashchange'); + +assert.strictEqual(typeof descriptor.get, 'function'); +assert.strictEqual(typeof descriptor.set, 'function'); +assert.strictEqual(descriptor.configurable, true); + +// Regression test for GH-42962. This assignment should not throw. +window.globalProxy.onhashchange = () => {}; + +assert.strictEqual(window.globalProxy.onhashchange, 42); + +function createWindow() { + const obj = {}; + vm.createContext(obj); + Object.defineProperty(obj, 'onhashchange', { + get: common.mustCall(() => 42), + set: common.mustCall(), + configurable: true + }); + + obj.globalProxy = vm.runInContext('this', obj); + + return obj; +} |