From: olehougaard Date: Tue, 18 Nov 2008 08:43:58 +0000 (+0000) Subject: Changing the semantics of cross-frame eval to be compatible with Safari and Firefox. X-Git-Tag: upstream/4.7.83~25000 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c9102021d09e5f6724a61588bd367a90a7ddddf;p=platform%2Fupstream%2Fv8.git Changing the semantics of cross-frame eval to be compatible with Safari and Firefox. Review URL: http://codereview.chromium.org/11601 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@781 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/runtime.cc b/src/runtime.cc index c33607788..f2b102d71 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -3956,29 +3956,8 @@ static Object* EvalContext() { Handle target = Top::global_context(); if (caller->global_context() == *target) return *caller; - // Compute a function closure that captures the calling context. We - // need a function that has trivial scope info, since it is only - // used to hold the context chain together. - Handle closure = Factory::NewFunction(Factory::empty_symbol(), - Factory::undefined_value()); - closure->set_context(*caller); - - // Create a new adaptor context that has the target environment as - // the extension object. This enables the evaluated code to see both - // the current context with locals and everything and to see global - // variables declared in the target global object. Furthermore, any - // properties introduced with 'var' will be added to the target - // global object because it is the extension object. - Handle adaptor = - Factory::NewFunctionContext(Context::MIN_CONTEXT_SLOTS, closure); - adaptor->set_extension(target->global()); - return *adaptor; -} - - -static Object* Runtime_EvalReceiver(Arguments args) { - StackFrameLocator locator; - return locator.FindJavaScriptFrame(1)->receiver(); + // Otherwise, use the global context from the other environment. + return *target; } diff --git a/src/runtime.h b/src/runtime.h index 36a7180eb..f0fdf1f5b 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -195,7 +195,6 @@ namespace v8 { namespace internal { F(GlobalPrint, 1) \ \ /* Eval */ \ - F(EvalReceiver, 1) \ F(GlobalReceiver, 1) \ \ F(SetProperty, -1 /* 3 or 4 */) \ diff --git a/src/v8natives.js b/src/v8natives.js index f3c98a5f8..21e3c93ee 100644 --- a/src/v8natives.js +++ b/src/v8natives.js @@ -113,7 +113,7 @@ function GlobalEval(x) { var f = %CompileString(x, 0, true); if (!IS_FUNCTION(f)) return f; - return f.call(%EvalReceiver(this)); + return f.call(this); } diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 82dac2584..7fba4f31b 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -4018,6 +4018,22 @@ THREADED_TEST(FunctionDescriptorException) { } +THREADED_TEST(Eval) { + v8::HandleScope scope; + LocalContext current; + + // Test that un-aliased eval uses local context. + Local