Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: always signal V8 for intercepted properties #42963

Merged
merged 1 commit into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,8 @@ void ContextifyContext::PropertySetterCallback(
!is_function)
return;

if (!is_declared_on_global_proxy && is_declared_on_sandbox &&
args.ShouldThrowOnError() && is_contextual_store && !is_function) {
// The property exists on the sandbox but not on the global
// proxy. Setting it would throw because we are in strict mode.
// Don't attempt to set it by signaling that the call was
// intercepted. Only change the value on the sandbox.
args.GetReturnValue().Set(false);
}

USE(ctx->sandbox()->Set(context, property, value));
args.GetReturnValue().Set(value);
}

// static
Expand Down
32 changes: 32 additions & 0 deletions test/parallel/test-vm-global-setter.js
Original file line number Diff line number Diff line change
@@ -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;
}