summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFeng Yu <F3n67u@outlook.com>2023-05-15 02:24:15 -0700
committerGitHub <noreply@github.com>2023-05-15 09:24:15 +0000
commit6bbf2a57fcf33266c5859497f8cc32e1389a358a (patch)
treee8c8f2e6dc32f3fa1236441c1d220fc03fb45374 /test
parent8b3777d0c82c01229e724d84586fdc472fd4deda (diff)
downloadnode-new-6bbf2a57fcf33266c5859497f8cc32e1389a358a.tar.gz
vm: fix crash when setting __proto__ on context's globalThis
PR-URL: https://github.com/nodejs/node/pull/47939 Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-vm-set-proto-null-on-globalthis.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/parallel/test-vm-set-proto-null-on-globalthis.js b/test/parallel/test-vm-set-proto-null-on-globalthis.js
new file mode 100644
index 0000000000..869124fa86
--- /dev/null
+++ b/test/parallel/test-vm-set-proto-null-on-globalthis.js
@@ -0,0 +1,13 @@
+'use strict';
+require('../common');
+
+// Setting __proto__ on vm context's globalThis should not cause a crash
+// Regression test for https://github.com/nodejs/node/issues/47798
+
+const vm = require('vm');
+const context = vm.createContext();
+
+const contextGlobalThis = vm.runInContext('this', context);
+
+// Should not crash.
+contextGlobalThis.__proto__ = null; // eslint-disable-line no-proto