mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
script.runIn*Context not throwing errors properly.
This commit is contained in:
@@ -166,7 +166,7 @@ Handle<Value> node::Script::EvalMachine(const Arguments& args) {
|
||||
}
|
||||
}
|
||||
if (result.IsEmpty()) {
|
||||
result = ThrowException(try_catch.Exception());
|
||||
return try_catch.ReThrow();
|
||||
} else if (cFlag == newContext) {
|
||||
// success! copy changes back onto the sandbox object.
|
||||
keys = context->Global()->GetPropertyNames();
|
||||
|
||||
@@ -63,7 +63,7 @@ class MessageTestCase(test.TestCase):
|
||||
pattern = '^%s$' % pattern
|
||||
patterns.append(pattern)
|
||||
# Compare actual output with the expected
|
||||
raw_lines = output.stdout.split('\n')
|
||||
raw_lines = (output.stdout + output.stderr).split('\n')
|
||||
outlines = [ s for s in raw_lines if not self.IgnoreLine(s) ]
|
||||
if len(outlines) != len(patterns):
|
||||
return True
|
||||
|
||||
11
test/message/undefined_reference_in_new_context.js
Normal file
11
test/message/undefined_reference_in_new_context.js
Normal file
@@ -0,0 +1,11 @@
|
||||
require('../common');
|
||||
|
||||
error('before');
|
||||
|
||||
var Script = process.binding('evals').Script;
|
||||
|
||||
// undefined reference
|
||||
script = new Script('foo.bar = 5;');
|
||||
script.runInNewContext();
|
||||
|
||||
error('after');
|
||||
14
test/message/undefined_reference_in_new_context.out
Normal file
14
test/message/undefined_reference_in_new_context.out
Normal file
@@ -0,0 +1,14 @@
|
||||
before
|
||||
|
||||
|
||||
/Users/ryan/projects/node/test/message/undefined_reference_in_new_context.js:9
|
||||
script.runInNewContext();
|
||||
^
|
||||
ReferenceError: foo is not defined
|
||||
at evalmachine.<anonymous>:1:1
|
||||
at Object.<anonymous> (/Users/ryan/projects/node/test/message/undefined_reference_in_new_context.js:9:8)
|
||||
at Module._compile (module:384:23)
|
||||
at Module._loadScriptSync (module:393:8)
|
||||
at Module.loadSync (module:296:10)
|
||||
at Object.runMain (module:447:22)
|
||||
at node.js:208:10
|
||||
@@ -15,6 +15,22 @@ assert.throws(function() {
|
||||
script.runInNewContext();
|
||||
});
|
||||
|
||||
|
||||
|
||||
debug('undefined reference');
|
||||
var error;
|
||||
script = new Script('foo.bar = 5;');
|
||||
try {
|
||||
script.runInNewContext();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
assert.ok(error);
|
||||
assert.ok(error.message.indexOf('not defined') >= 0);
|
||||
|
||||
debug('error.message: ' + error.message);
|
||||
|
||||
|
||||
hello = 5;
|
||||
script = new Script('hello = 2');
|
||||
script.runInNewContext();
|
||||
|
||||
Reference in New Issue
Block a user