Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/node_contextify.cc10
-rw-r--r--test/parallel/test-vm-global-setter.js32
2 files changed, 33 insertions, 9 deletions
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 482c9a7b51d..b2df392697c 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -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
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;
+}