| OLD | NEW |
| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 context_( | 136 context_( |
| 137 v8::Context::New(v8::Isolate::GetCurrent(), | 137 v8::Context::New(v8::Isolate::GetCurrent(), |
| 138 extensions, | 138 extensions, |
| 139 global_template, | 139 global_template, |
| 140 global_object)) { | 140 global_object)) { |
| 141 context_->Enter(); | 141 context_->Enter(); |
| 142 } | 142 } |
| 143 inline ~DebugLocalContext() { | 143 inline ~DebugLocalContext() { |
| 144 context_->Exit(); | 144 context_->Exit(); |
| 145 } | 145 } |
| 146 inline v8::Local<v8::Context> context() { return context_; } |
| 146 inline v8::Context* operator->() { return *context_; } | 147 inline v8::Context* operator->() { return *context_; } |
| 147 inline v8::Context* operator*() { return *context_; } | 148 inline v8::Context* operator*() { return *context_; } |
| 148 inline bool IsReady() { return !context_.IsEmpty(); } | 149 inline bool IsReady() { return !context_.IsEmpty(); } |
| 149 void ExposeDebug() { | 150 void ExposeDebug() { |
| 150 v8::internal::Isolate* isolate = | 151 v8::internal::Isolate* isolate = |
| 151 reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate()); | 152 reinterpret_cast<v8::internal::Isolate*>(context_->GetIsolate()); |
| 152 v8::internal::Factory* factory = isolate->factory(); | 153 v8::internal::Factory* factory = isolate->factory(); |
| 153 v8::internal::Debug* debug = isolate->debug(); | 154 v8::internal::Debug* debug = isolate->debug(); |
| 154 // Expose the debug context global object in the global object for testing. | 155 // Expose the debug context global object in the global object for testing. |
| 155 debug->Load(); | 156 debug->Load(); |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 782 |
| 782 // Count the number of breaks. | 783 // Count the number of breaks. |
| 783 if (event == v8::Break) { | 784 if (event == v8::Break) { |
| 784 break_point_hit_count++; | 785 break_point_hit_count++; |
| 785 } else if (event == v8::Exception) { | 786 } else if (event == v8::Exception) { |
| 786 exception_hit_count++; | 787 exception_hit_count++; |
| 787 | 788 |
| 788 // Check whether the exception was uncaught. | 789 // Check whether the exception was uncaught. |
| 789 v8::Local<v8::String> fun_name = v8::String::New("uncaught"); | 790 v8::Local<v8::String> fun_name = v8::String::New("uncaught"); |
| 790 v8::Local<v8::Function> fun = | 791 v8::Local<v8::Function> fun = |
| 791 v8::Function::Cast(*event_data->Get(fun_name)); | 792 v8::Local<v8::Function>::Cast(event_data->Get(fun_name)); |
| 792 v8::Local<v8::Value> result = *fun->Call(event_data, 0, NULL); | 793 v8::Local<v8::Value> result = fun->Call(event_data, 0, NULL); |
| 793 if (result->IsTrue()) { | 794 if (result->IsTrue()) { |
| 794 uncaught_exception_hit_count++; | 795 uncaught_exception_hit_count++; |
| 795 } | 796 } |
| 796 } | 797 } |
| 797 | 798 |
| 798 // Collect the JavsScript stack height if the function frame_count is | 799 // Collect the JavsScript stack height if the function frame_count is |
| 799 // compiled. | 800 // compiled. |
| 800 if (!frame_count.IsEmpty()) { | 801 if (!frame_count.IsEmpty()) { |
| 801 static const int kArgc = 1; | 802 static const int kArgc = 1; |
| 802 v8::Handle<v8::Value> argv[kArgc] = { exec_state }; | 803 v8::Handle<v8::Value> argv[kArgc] = { exec_state }; |
| (...skipping 5647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6450 v8::Handle<v8::String> data_1 = v8::String::New("1"); | 6451 v8::Handle<v8::String> data_1 = v8::String::New("1"); |
| 6451 context_1->SetEmbedderData(0, data_1); | 6452 context_1->SetEmbedderData(0, data_1); |
| 6452 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); | 6453 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); |
| 6453 | 6454 |
| 6454 // Simple test function with eval that causes a break. | 6455 // Simple test function with eval that causes a break. |
| 6455 const char* source = "function f() { eval('debugger;'); }"; | 6456 const char* source = "function f() { eval('debugger;'); }"; |
| 6456 | 6457 |
| 6457 // Enter and run function in the context. | 6458 // Enter and run function in the context. |
| 6458 { | 6459 { |
| 6459 v8::Context::Scope context_scope(context_1); | 6460 v8::Context::Scope context_scope(context_1); |
| 6460 expected_context = v8::Local<v8::Context>(*context_1); | 6461 expected_context = context_1; |
| 6461 expected_context_data = data_1; | 6462 expected_context_data = data_1; |
| 6462 v8::Local<v8::Function> f = CompileFunction(source, "f"); | 6463 v8::Local<v8::Function> f = CompileFunction(source, "f"); |
| 6463 f->Call(context_1->Global(), 0, NULL); | 6464 f->Call(context_1->Global(), 0, NULL); |
| 6464 } | 6465 } |
| 6465 } | 6466 } |
| 6466 | 6467 |
| 6467 | 6468 |
| 6468 // Test which creates a context and sets embedder data on it. Checks that this | 6469 // Test which creates a context and sets embedder data on it. Checks that this |
| 6469 // data is set correctly and that when the debug message handler is called for | 6470 // data is set correctly and that when the debug message handler is called for |
| 6470 // break event in an eval statement the expected context is the one returned by | 6471 // break event in an eval statement the expected context is the one returned by |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7034 // an object with property 'a' == 1. If the property has custom accessor | 7035 // an object with property 'a' == 1. If the property has custom accessor |
| 7035 // this handler will eventually invoke it. | 7036 // this handler will eventually invoke it. |
| 7036 static void DebugEventGetAtgumentPropertyValue( | 7037 static void DebugEventGetAtgumentPropertyValue( |
| 7037 v8::DebugEvent event, | 7038 v8::DebugEvent event, |
| 7038 v8::Handle<v8::Object> exec_state, | 7039 v8::Handle<v8::Object> exec_state, |
| 7039 v8::Handle<v8::Object> event_data, | 7040 v8::Handle<v8::Object> event_data, |
| 7040 v8::Handle<v8::Value> data) { | 7041 v8::Handle<v8::Value> data) { |
| 7041 if (event == v8::Break) { | 7042 if (event == v8::Break) { |
| 7042 break_point_hit_count++; | 7043 break_point_hit_count++; |
| 7043 CHECK(debugger_context == v8::Context::GetCurrent()); | 7044 CHECK(debugger_context == v8::Context::GetCurrent()); |
| 7044 v8::Handle<v8::Function> func(v8::Function::Cast(*CompileRun( | 7045 v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(CompileRun( |
| 7045 "(function(exec_state) {\n" | 7046 "(function(exec_state) {\n" |
| 7046 " return (exec_state.frame(0).argumentValue(0).property('a').\n" | 7047 " return (exec_state.frame(0).argumentValue(0).property('a').\n" |
| 7047 " value().value() == 1);\n" | 7048 " value().value() == 1);\n" |
| 7048 "})"))); | 7049 "})")); |
| 7049 const int argc = 1; | 7050 const int argc = 1; |
| 7050 v8::Handle<v8::Value> argv[argc] = { exec_state }; | 7051 v8::Handle<v8::Value> argv[argc] = { exec_state }; |
| 7051 v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv); | 7052 v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv); |
| 7052 CHECK(result->IsTrue()); | 7053 CHECK(result->IsTrue()); |
| 7053 } | 7054 } |
| 7054 } | 7055 } |
| 7055 | 7056 |
| 7056 | 7057 |
| 7057 TEST(CallingContextIsNotDebugContext) { | 7058 TEST(CallingContextIsNotDebugContext) { |
| 7058 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); | 7059 v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); |
| 7059 // Create and enter a debugee context. | 7060 // Create and enter a debugee context. |
| 7060 DebugLocalContext env; | 7061 DebugLocalContext env; |
| 7061 v8::HandleScope scope(env->GetIsolate()); | 7062 v8::HandleScope scope(env->GetIsolate()); |
| 7062 env.ExposeDebug(); | 7063 env.ExposeDebug(); |
| 7063 | 7064 |
| 7064 // Save handles to the debugger and debugee contexts to be used in | 7065 // Save handles to the debugger and debugee contexts to be used in |
| 7065 // NamedGetterWithCallingContextCheck. | 7066 // NamedGetterWithCallingContextCheck. |
| 7066 debugee_context = v8::Local<v8::Context>(*env); | 7067 debugee_context = env.context(); |
| 7067 debugger_context = v8::Utils::ToLocal(debug->debug_context()); | 7068 debugger_context = v8::Utils::ToLocal(debug->debug_context()); |
| 7068 | 7069 |
| 7069 // Create object with 'a' property accessor. | 7070 // Create object with 'a' property accessor. |
| 7070 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); | 7071 v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); |
| 7071 named->SetAccessor(v8::String::New("a"), | 7072 named->SetAccessor(v8::String::New("a"), |
| 7072 NamedGetterWithCallingContextCheck); | 7073 NamedGetterWithCallingContextCheck); |
| 7073 env->Global()->Set(v8::String::New("obj"), | 7074 env->Global()->Set(v8::String::New("obj"), |
| 7074 named->NewInstance()); | 7075 named->NewInstance()); |
| 7075 | 7076 |
| 7076 // Register the debug event listener | 7077 // Register the debug event listener |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7571 TEST(LiveEditDisabled) { | 7572 TEST(LiveEditDisabled) { |
| 7572 v8::internal::FLAG_allow_natives_syntax = true; | 7573 v8::internal::FLAG_allow_natives_syntax = true; |
| 7573 LocalContext env; | 7574 LocalContext env; |
| 7574 v8::HandleScope scope(env->GetIsolate()); | 7575 v8::HandleScope scope(env->GetIsolate()); |
| 7575 v8::Debug::SetLiveEditEnabled(false); | 7576 v8::Debug::SetLiveEditEnabled(false); |
| 7576 CompileRun("%LiveEditCompareStrings('', '')"); | 7577 CompileRun("%LiveEditCompareStrings('', '')"); |
| 7577 } | 7578 } |
| 7578 | 7579 |
| 7579 | 7580 |
| 7580 #endif // ENABLE_DEBUGGER_SUPPORT | 7581 #endif // ENABLE_DEBUGGER_SUPPORT |
| OLD | NEW |