Browse Source

Make test-global work with NODE_MODULE_CONTEXTS.

v0.7.4-release
Herbert Vojčík 15 years ago
committed by Ryan Dahl
parent
commit
71651bf8b2
  1. 1
      src/node.js
  2. 2
      src/node_script.cc

1
src/node.js

@ -433,6 +433,7 @@ var module = (function () {
sandbox.__filename = filename; sandbox.__filename = filename;
sandbox.__dirname = dirname; sandbox.__dirname = dirname;
sandbox.module = self; sandbox.module = self;
sandbox.global = sandbox;
sandbox.root = root; sandbox.root = root;
Script.runInNewContext(content, sandbox, filename); Script.runInNewContext(content, sandbox, filename);

2
src/node_script.cc

@ -212,6 +212,7 @@ template <node::Script::EvalInputFlags iFlag,
for (i = 0; i < keys->Length(); i++) { for (i = 0; i < keys->Length(); i++) {
Handle<String> key = keys->Get(Integer::New(i))->ToString(); Handle<String> key = keys->Get(Integer::New(i))->ToString();
Handle<Value> value = sandbox->Get(key); Handle<Value> value = sandbox->Get(key);
if (value == sandbox) { value = context->Global(); }
context->Global()->Set(key, value); context->Global()->Set(key, value);
} }
} }
@ -264,6 +265,7 @@ template <node::Script::EvalInputFlags iFlag,
for (i = 0; i < keys->Length(); i++) { for (i = 0; i < keys->Length(); i++) {
Handle<String> key = keys->Get(Integer::New(i))->ToString(); Handle<String> key = keys->Get(Integer::New(i))->ToString();
Handle<Value> value = context->Global()->Get(key); Handle<Value> value = context->Global()->Get(key);
if (value == context->Global()) { value = sandbox; }
sandbox->Set(key, value); sandbox->Set(key, value);
} }
} }

Loading…
Cancel
Save