From 71651bf8b240c985129f16545ded0bd14f6cee93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herbert=20Voj=C4=8D=C3=ADk?= Date: Fri, 20 Aug 2010 18:59:33 +0200 Subject: [PATCH] Make test-global work with NODE_MODULE_CONTEXTS. --- src/node.js | 1 + src/node_script.cc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/node.js b/src/node.js index 9d94f88d934..e16f13ecb0a 100644 --- a/src/node.js +++ b/src/node.js @@ -433,6 +433,7 @@ var module = (function () { sandbox.__filename = filename; sandbox.__dirname = dirname; sandbox.module = self; + sandbox.global = sandbox; sandbox.root = root; Script.runInNewContext(content, sandbox, filename); diff --git a/src/node_script.cc b/src/node_script.cc index cbe8d12b5d2..d9631ec2f31 100644 --- a/src/node_script.cc +++ b/src/node_script.cc @@ -212,6 +212,7 @@ template Length(); i++) { Handle key = keys->Get(Integer::New(i))->ToString(); Handle value = sandbox->Get(key); + if (value == sandbox) { value = context->Global(); } context->Global()->Set(key, value); } } @@ -264,6 +265,7 @@ template Length(); i++) { Handle key = keys->Get(Integer::New(i))->ToString(); Handle value = context->Global()->Get(key); + if (value == context->Global()) { value = sandbox; } sandbox->Set(key, value); } }