Skip to content

Commit 38e4c15

Browse files
targosRafaelGSS
authored andcommitted
src: always signal V8 for intercepted properties
Closes: #42962 PR-URL: #42963 Fixes: #42962 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 5470578 commit 38e4c15

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

src/node_contextify.cc

+1-9
Original file line numberDiff line numberDiff line change
@@ -449,16 +449,8 @@ void ContextifyContext::PropertySetterCallback(
449449
!is_function)
450450
return;
451451

452-
if (!is_declared_on_global_proxy && is_declared_on_sandbox &&
453-
args.ShouldThrowOnError() && is_contextual_store && !is_function) {
454-
// The property exists on the sandbox but not on the global
455-
// proxy. Setting it would throw because we are in strict mode.
456-
// Don't attempt to set it by signaling that the call was
457-
// intercepted. Only change the value on the sandbox.
458-
args.GetReturnValue().Set(false);
459-
}
460-
461452
USE(ctx->sandbox()->Set(context, property, value));
453+
args.GetReturnValue().Set(value);
462454
}
463455

464456
// static
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const vm = require('vm');
5+
6+
const window = createWindow();
7+
8+
const descriptor =
9+
Object.getOwnPropertyDescriptor(window.globalProxy, 'onhashchange');
10+
11+
assert.strictEqual(typeof descriptor.get, 'function');
12+
assert.strictEqual(typeof descriptor.set, 'function');
13+
assert.strictEqual(descriptor.configurable, true);
14+
15+
// Regression test for GH-42962. This assignment should not throw.
16+
window.globalProxy.onhashchange = () => {};
17+
18+
assert.strictEqual(window.globalProxy.onhashchange, 42);
19+
20+
function createWindow() {
21+
const obj = {};
22+
vm.createContext(obj);
23+
Object.defineProperty(obj, 'onhashchange', {
24+
get: common.mustCall(() => 42),
25+
set: common.mustCall(),
26+
configurable: true
27+
});
28+
29+
obj.globalProxy = vm.runInContext('this', obj);
30+
31+
return obj;
32+
}

0 commit comments

Comments
 (0)