Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(964)

Side by Side Diff: test/cctest/test-api.cc

Issue 294073002: filter cross context eval (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 22685 matching lines...) Expand 10 before | Expand all | Expand 10 after
22696 Local<Script> script = v8::ScriptCompiler::Compile( 22696 Local<Script> script = v8::ScriptCompiler::Compile(
22697 isolate, &script_source); 22697 isolate, &script_source);
22698 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); 22698 Local<Value> script_name = script->GetUnboundScript()->GetScriptName();
22699 CHECK(!script_name.IsEmpty()); 22699 CHECK(!script_name.IsEmpty());
22700 CHECK(script_name->IsString()); 22700 CHECK(script_name->IsString());
22701 String::Utf8Value utf8_name(script_name); 22701 String::Utf8Value utf8_name(script_name);
22702 CHECK_EQ(url, *utf8_name); 22702 CHECK_EQ(url, *utf8_name);
22703 int line_number = script->GetUnboundScript()->GetLineNumber(0); 22703 int line_number = script->GetUnboundScript()->GetLineNumber(0);
22704 CHECK_EQ(13, line_number); 22704 CHECK_EQ(13, line_number);
22705 } 22705 }
22706
22707
22708 Local<v8::Context> call_eval_context;
22709 Local<v8::Function> call_eval_bound_function;
22710 static void CallEval(const v8::FunctionCallbackInfo<v8::Value>& args) {
22711 v8::Context::Scope scope(call_eval_context);
22712 args.GetReturnValue().Set(
22713 call_eval_bound_function->Call(call_eval_context->Global(), 0, NULL));
22714 }
22715
22716
22717 TEST(CrossActivationEval) {
22718 LocalContext env;
22719 v8::Isolate* isolate = env->GetIsolate();
22720 v8::HandleScope scope(isolate);
22721 {
22722 call_eval_context = v8::Context::New(isolate);
22723 v8::Context::Scope scope(call_eval_context);
22724 call_eval_bound_function =
22725 Local<Function>::Cast(CompileRun("eval.bind(this, '1')"));
22726 }
22727 env->Global()->Set(v8_str("CallEval"),
22728 v8::FunctionTemplate::New(isolate, CallEval)->GetFunction());
22729 Local<Value> result = CompileRun("CallEval();");
22730 CHECK_EQ(result, v8::Integer::New(isolate, 1));
22731 }
OLDNEW
« src/runtime.cc ('K') | « src/v8natives.js ('k') | test/mjsunit/cross-realm-filtering.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698