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

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
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/cross-realm-filtering.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 22696 matching lines...) Expand 10 before | Expand all | Expand 10 after
22707 Local<Script> script = v8::ScriptCompiler::Compile( 22707 Local<Script> script = v8::ScriptCompiler::Compile(
22708 isolate, &script_source); 22708 isolate, &script_source);
22709 Local<Value> script_name = script->GetUnboundScript()->GetScriptName(); 22709 Local<Value> script_name = script->GetUnboundScript()->GetScriptName();
22710 CHECK(!script_name.IsEmpty()); 22710 CHECK(!script_name.IsEmpty());
22711 CHECK(script_name->IsString()); 22711 CHECK(script_name->IsString());
22712 String::Utf8Value utf8_name(script_name); 22712 String::Utf8Value utf8_name(script_name);
22713 CHECK_EQ(url, *utf8_name); 22713 CHECK_EQ(url, *utf8_name);
22714 int line_number = script->GetUnboundScript()->GetLineNumber(0); 22714 int line_number = script->GetUnboundScript()->GetLineNumber(0);
22715 CHECK_EQ(13, line_number); 22715 CHECK_EQ(13, line_number);
22716 } 22716 }
22717
22718
22719 Local<v8::Context> call_eval_context;
22720 Local<v8::Function> call_eval_bound_function;
22721 static void CallEval(const v8::FunctionCallbackInfo<v8::Value>& args) {
22722 v8::Context::Scope scope(call_eval_context);
22723 args.GetReturnValue().Set(
22724 call_eval_bound_function->Call(call_eval_context->Global(), 0, NULL));
22725 }
22726
22727
22728 TEST(CrossActivationEval) {
22729 LocalContext env;
22730 v8::Isolate* isolate = env->GetIsolate();
22731 v8::HandleScope scope(isolate);
22732 {
22733 call_eval_context = v8::Context::New(isolate);
22734 v8::Context::Scope scope(call_eval_context);
22735 call_eval_bound_function =
22736 Local<Function>::Cast(CompileRun("eval.bind(this, '1')"));
22737 }
22738 env->Global()->Set(v8_str("CallEval"),
22739 v8::FunctionTemplate::New(isolate, CallEval)->GetFunction());
22740 Local<Value> result = CompileRun("CallEval();");
22741 CHECK_EQ(result, v8::Integer::New(isolate, 1));
22742 }
OLDNEW
« no previous file with comments | « 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