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>
32 lines
844 B
JavaScript
32 lines
844 B
JavaScript
'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;
|
|
}
|