From 31b59400f8527ea98b03ca23ae26f8d19e56c5f2 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 4 Aug 2010 10:20:40 -0700 Subject: [PATCH] Allow null context in Script --- src/node_script.cc | 2 +- test/simple/test-script-context.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node_script.cc b/src/node_script.cc index 1e32b0f133..cbe8d12b5d 100644 --- a/src/node_script.cc +++ b/src/node_script.cc @@ -175,7 +175,7 @@ template sandbox; if (cFlag == newContext) { - sandbox = args.Length() > sbIndex ? args[sbIndex]->ToObject() : Object::New(); + sandbox = args[sbIndex]->IsObject() ? args[sbIndex]->ToObject() : Object::New(); } else if (cFlag == userContext) { sandbox = args[sbIndex]->ToObject(); } diff --git a/test/simple/test-script-context.js b/test/simple/test-script-context.js index 343eeabc62..40a46c7009 100644 --- a/test/simple/test-script-context.js +++ b/test/simple/test-script-context.js @@ -19,3 +19,7 @@ script = new Script('foo = 3;'); result = script.runInContext(context); assert.equal(3, context.foo); assert.equal('lala', context.thing); + + +// Issue GH-227: +Script.runInNewContext('', null, 'some.js');