Review URL: http://codereview.chromium.org/10748
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@757
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
function GlobalEval(x) {
if (!IS_STRING(x)) return x;
+ if (this !== %GlobalReceiver(global)) {
+ throw $EvalError('The "this" object passed to eval ' +
+ 'must be the global object from which eval originated');
+ }
+
var f = %CompileString(x, 0, true);
if (!IS_FUNCTION(f)) return f;
"with({x:2}){other.eval('x+y')}"));
result = script->Run();
CHECK_EQ(3, result->Int32Value());
+
+ // Check that you cannot use 'eval.call' with another object than the
+ // current global object.
+ v8::TryCatch try_catch;
+ script =
+ Script::Compile(v8_str("other.y = 1; eval.call(other, 'y')"));
+ result = script->Run();
+ CHECK(try_catch.HasCaught());
}