aboutsummaryrefslogtreecommitdiff
path: root/test/sandbox.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-13 18:05:07 +0000
committerGitHub <noreply@github.com>2020-12-14 02:05:07 +0800
commitf579f1aa47a0ba13955433b90b56bea241849f83 (patch)
tree2aa39c1d9d4f103cd94c0336fe6ca7ff25a0b9b4 /test/sandbox.js
parentfcc40d0502a29e09a164ca04603db33b7dedfc3c (diff)
downloadtracifyjs-f579f1aa47a0ba13955433b90b56bea241849f83.tar.gz
tracifyjs-f579f1aa47a0ba13955433b90b56bea241849f83.zip
emulate global context in Node.js & web (#4379)
Diffstat (limited to 'test/sandbox.js')
-rw-r--r--test/sandbox.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/sandbox.js b/test/sandbox.js
index 46b1a410..f659427d 100644
--- a/test/sandbox.js
+++ b/test/sandbox.js
@@ -26,10 +26,19 @@ var setupContext = new vm.Script([
]).join("\n"));
function createContext() {
- var ctx = vm.createContext(Object.defineProperty({}, "console", { value: { log: log } }));
+ var ctx = vm.createContext(Object.defineProperties({}, {
+ console: { value: { log: log } },
+ global: { get: self },
+ self: { get: self },
+ window: { get: self },
+ }));
var global = setupContext.runInContext(ctx);
return ctx;
+ function self() {
+ return this;
+ }
+
function safe_log(arg, level) {
if (arg) switch (typeof arg) {
case "function":