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

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

Issue 24345003: remove Isolate::GetCurrent from Context api functions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments Created 7 years, 2 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 | « test/cctest/test-api.cc ('k') | test/cctest/test-heap.cc » ('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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 v8::Script::Compile(v8::String::New(source))->Run(); 193 v8::Script::Compile(v8::String::New(source))->Run();
194 return v8::Local<v8::Function>::Cast( 194 return v8::Local<v8::Function>::Cast(
195 (*env)->Global()->Get(v8::String::New(function_name))); 195 (*env)->Global()->Get(v8::String::New(function_name)));
196 } 196 }
197 197
198 198
199 // Compile and run the supplied source and return the requested function. 199 // Compile and run the supplied source and return the requested function.
200 static v8::Local<v8::Function> CompileFunction(const char* source, 200 static v8::Local<v8::Function> CompileFunction(const char* source,
201 const char* function_name) { 201 const char* function_name) {
202 v8::Script::Compile(v8::String::New(source))->Run(); 202 v8::Script::Compile(v8::String::New(source))->Run();
203 v8::Local<v8::Object> global =
204 CcTest::isolate()->GetCurrentContext()->Global();
203 return v8::Local<v8::Function>::Cast( 205 return v8::Local<v8::Function>::Cast(
204 v8::Context::GetCurrent()->Global()->Get(v8::String::New(function_name))); 206 global->Get(v8::String::New(function_name)));
205 } 207 }
206 208
207 209
208 // Is there any debug info for the function? 210 // Is there any debug info for the function?
209 static bool HasDebugInfo(v8::Handle<v8::Function> fun) { 211 static bool HasDebugInfo(v8::Handle<v8::Function> fun) {
210 Handle<v8::internal::JSFunction> f = v8::Utils::OpenHandle(*fun); 212 Handle<v8::internal::JSFunction> f = v8::Utils::OpenHandle(*fun);
211 Handle<v8::internal::SharedFunctionInfo> shared(f->shared()); 213 Handle<v8::internal::SharedFunctionInfo> shared(f->shared());
212 return Debug::HasDebugInfo(shared); 214 return Debug::HasDebugInfo(shared);
213 } 215 }
214 216
(...skipping 6785 matching lines...) Expand 10 before | Expand all | Expand 10 after
7000 v8::Handle<v8::Context> debugee_context; 7002 v8::Handle<v8::Context> debugee_context;
7001 v8::Handle<v8::Context> debugger_context; 7003 v8::Handle<v8::Context> debugger_context;
7002 7004
7003 7005
7004 // Property getter that checks that current and calling contexts 7006 // Property getter that checks that current and calling contexts
7005 // are both the debugee contexts. 7007 // are both the debugee contexts.
7006 static void NamedGetterWithCallingContextCheck( 7008 static void NamedGetterWithCallingContextCheck(
7007 v8::Local<v8::String> name, 7009 v8::Local<v8::String> name,
7008 const v8::PropertyCallbackInfo<v8::Value>& info) { 7010 const v8::PropertyCallbackInfo<v8::Value>& info) {
7009 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(name), "a")); 7011 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(name), "a"));
7010 v8::Handle<v8::Context> current = v8::Context::GetCurrent(); 7012 v8::Handle<v8::Context> current = info.GetIsolate()->GetCurrentContext();
7011 CHECK(current == debugee_context); 7013 CHECK(current == debugee_context);
7012 CHECK(current != debugger_context); 7014 CHECK(current != debugger_context);
7013 v8::Handle<v8::Context> calling = v8::Context::GetCalling(); 7015 v8::Handle<v8::Context> calling = info.GetIsolate()->GetCallingContext();
7014 CHECK(calling == debugee_context); 7016 CHECK(calling == debugee_context);
7015 CHECK(calling != debugger_context); 7017 CHECK(calling != debugger_context);
7016 info.GetReturnValue().Set(1); 7018 info.GetReturnValue().Set(1);
7017 } 7019 }
7018 7020
7019 7021
7020 // Debug event listener that checks if the first argument of a function is 7022 // Debug event listener that checks if the first argument of a function is
7021 // an object with property 'a' == 1. If the property has custom accessor 7023 // an object with property 'a' == 1. If the property has custom accessor
7022 // this handler will eventually invoke it. 7024 // this handler will eventually invoke it.
7023 static void DebugEventGetAtgumentPropertyValue( 7025 static void DebugEventGetAtgumentPropertyValue(
7024 const v8::Debug::EventDetails& event_details) { 7026 const v8::Debug::EventDetails& event_details) {
7025 v8::DebugEvent event = event_details.GetEvent(); 7027 v8::DebugEvent event = event_details.GetEvent();
7026 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState(); 7028 v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
7027 if (event == v8::Break) { 7029 if (event == v8::Break) {
7028 break_point_hit_count++; 7030 break_point_hit_count++;
7029 CHECK(debugger_context == v8::Context::GetCurrent()); 7031 CHECK(debugger_context == CcTest::isolate()->GetCurrentContext());
7030 v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(CompileRun( 7032 v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(CompileRun(
7031 "(function(exec_state) {\n" 7033 "(function(exec_state) {\n"
7032 " return (exec_state.frame(0).argumentValue(0).property('a').\n" 7034 " return (exec_state.frame(0).argumentValue(0).property('a').\n"
7033 " value().value() == 1);\n" 7035 " value().value() == 1);\n"
7034 "})")); 7036 "})"));
7035 const int argc = 1; 7037 const int argc = 1;
7036 v8::Handle<v8::Value> argv[argc] = { exec_state }; 7038 v8::Handle<v8::Value> argv[argc] = { exec_state };
7037 v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv); 7039 v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv);
7038 CHECK(result->IsTrue()); 7040 CHECK(result->IsTrue());
7039 } 7041 }
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
7551 TEST(LiveEditDisabled) { 7553 TEST(LiveEditDisabled) {
7552 v8::internal::FLAG_allow_natives_syntax = true; 7554 v8::internal::FLAG_allow_natives_syntax = true;
7553 LocalContext env; 7555 LocalContext env;
7554 v8::HandleScope scope(env->GetIsolate()); 7556 v8::HandleScope scope(env->GetIsolate());
7555 v8::Debug::SetLiveEditEnabled(false), env->GetIsolate(); 7557 v8::Debug::SetLiveEditEnabled(false), env->GetIsolate();
7556 CompileRun("%LiveEditCompareStrings('', '')"); 7558 CompileRun("%LiveEditCompareStrings('', '')");
7557 } 7559 }
7558 7560
7559 7561
7560 #endif // ENABLE_DEBUGGER_SUPPORT 7562 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698