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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifdef ENABLE_DEBUGGER_SUPPORT | 28 #ifdef ENABLE_DEBUGGER_SUPPORT |
29 | 29 |
30 // TODO(svenpanne): Do not use Context::GetData and Context::SetData. | |
31 #define V8_DISABLE_DEPRECATIONS 1 | |
32 | |
33 #include <stdlib.h> | 30 #include <stdlib.h> |
34 | 31 |
35 #include "v8.h" | 32 #include "v8.h" |
36 | 33 |
37 #include "api.h" | 34 #include "api.h" |
38 #include "cctest.h" | 35 #include "cctest.h" |
39 #include "compilation-cache.h" | 36 #include "compilation-cache.h" |
40 #include "debug.h" | 37 #include "debug.h" |
41 #include "deoptimizer.h" | 38 #include "deoptimizer.h" |
42 #include "platform.h" | 39 #include "platform.h" |
(...skipping 6172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6215 } | 6212 } |
6216 | 6213 |
6217 | 6214 |
6218 static v8::Persistent<v8::Context> expected_context; | 6215 static v8::Persistent<v8::Context> expected_context; |
6219 static v8::Handle<v8::Value> expected_context_data; | 6216 static v8::Handle<v8::Value> expected_context_data; |
6220 | 6217 |
6221 | 6218 |
6222 // Check that the expected context is the one generating the debug event. | 6219 // Check that the expected context is the one generating the debug event. |
6223 static void ContextCheckMessageHandler(const v8::Debug::Message& message) { | 6220 static void ContextCheckMessageHandler(const v8::Debug::Message& message) { |
6224 CHECK(message.GetEventContext() == expected_context); | 6221 CHECK(message.GetEventContext() == expected_context); |
6225 CHECK(message.GetEventContext()->GetData()->StrictEquals( | 6222 CHECK(message.GetEventContext()->GetEmbedderData(0)->StrictEquals( |
6226 expected_context_data)); | 6223 expected_context_data)); |
6227 message_handler_hit_count++; | 6224 message_handler_hit_count++; |
6228 | 6225 |
6229 static char print_buffer[1000]; | 6226 static char print_buffer[1000]; |
6230 v8::String::Value json(message.GetJSON()); | 6227 v8::String::Value json(message.GetJSON()); |
6231 Utf16ToAscii(*json, json.length(), print_buffer); | 6228 Utf16ToAscii(*json, json.length(), print_buffer); |
6232 | 6229 |
6233 // Send a continue command for break events. | 6230 // Send a continue command for break events. |
6234 if (IsBreakEventMessage(print_buffer)) { | 6231 if (IsBreakEventMessage(print_buffer)) { |
6235 SendContinueCommand(); | 6232 SendContinueCommand(); |
(...skipping 12 matching lines...) Expand all Loading... |
6248 // Create two contexts. | 6245 // Create two contexts. |
6249 v8::Persistent<v8::Context> context_1; | 6246 v8::Persistent<v8::Context> context_1; |
6250 v8::Persistent<v8::Context> context_2; | 6247 v8::Persistent<v8::Context> context_2; |
6251 v8::Handle<v8::ObjectTemplate> global_template = | 6248 v8::Handle<v8::ObjectTemplate> global_template = |
6252 v8::Handle<v8::ObjectTemplate>(); | 6249 v8::Handle<v8::ObjectTemplate>(); |
6253 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>(); | 6250 v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>(); |
6254 context_1 = v8::Context::New(NULL, global_template, global_object); | 6251 context_1 = v8::Context::New(NULL, global_template, global_object); |
6255 context_2 = v8::Context::New(NULL, global_template, global_object); | 6252 context_2 = v8::Context::New(NULL, global_template, global_object); |
6256 | 6253 |
6257 // Default data value is undefined. | 6254 // Default data value is undefined. |
6258 CHECK(context_1->GetData()->IsUndefined()); | 6255 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); |
6259 CHECK(context_2->GetData()->IsUndefined()); | 6256 CHECK(context_2->GetEmbedderData(0)->IsUndefined()); |
6260 | 6257 |
6261 // Set and check different data values. | 6258 // Set and check different data values. |
6262 v8::Handle<v8::String> data_1 = v8::String::New("1"); | 6259 v8::Handle<v8::String> data_1 = v8::String::New("1"); |
6263 v8::Handle<v8::String> data_2 = v8::String::New("2"); | 6260 v8::Handle<v8::String> data_2 = v8::String::New("2"); |
6264 context_1->SetData(data_1); | 6261 context_1->SetEmbedderData(0, data_1); |
6265 context_2->SetData(data_2); | 6262 context_2->SetEmbedderData(0, data_2); |
6266 CHECK(context_1->GetData()->StrictEquals(data_1)); | 6263 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); |
6267 CHECK(context_2->GetData()->StrictEquals(data_2)); | 6264 CHECK(context_2->GetEmbedderData(0)->StrictEquals(data_2)); |
6268 | 6265 |
6269 // Simple test function which causes a break. | 6266 // Simple test function which causes a break. |
6270 const char* source = "function f() { debugger; }"; | 6267 const char* source = "function f() { debugger; }"; |
6271 | 6268 |
6272 // Enter and run function in the first context. | 6269 // Enter and run function in the first context. |
6273 { | 6270 { |
6274 v8::Context::Scope context_scope(context_1); | 6271 v8::Context::Scope context_scope(context_1); |
6275 expected_context = context_1; | 6272 expected_context = context_1; |
6276 expected_context_data = data_1; | 6273 expected_context_data = data_1; |
6277 v8::Local<v8::Function> f = CompileFunction(source, "f"); | 6274 v8::Local<v8::Function> f = CompileFunction(source, "f"); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6412 | 6409 |
6413 // Common part of EvalContextData and NestedBreakEventContextData tests. | 6410 // Common part of EvalContextData and NestedBreakEventContextData tests. |
6414 static void ExecuteScriptForContextCheck() { | 6411 static void ExecuteScriptForContextCheck() { |
6415 // Create a context. | 6412 // Create a context. |
6416 v8::Persistent<v8::Context> context_1; | 6413 v8::Persistent<v8::Context> context_1; |
6417 v8::Handle<v8::ObjectTemplate> global_template = | 6414 v8::Handle<v8::ObjectTemplate> global_template = |
6418 v8::Handle<v8::ObjectTemplate>(); | 6415 v8::Handle<v8::ObjectTemplate>(); |
6419 context_1 = v8::Context::New(NULL, global_template); | 6416 context_1 = v8::Context::New(NULL, global_template); |
6420 | 6417 |
6421 // Default data value is undefined. | 6418 // Default data value is undefined. |
6422 CHECK(context_1->GetData()->IsUndefined()); | 6419 CHECK(context_1->GetEmbedderData(0)->IsUndefined()); |
6423 | 6420 |
6424 // Set and check a data value. | 6421 // Set and check a data value. |
6425 v8::Handle<v8::String> data_1 = v8::String::New("1"); | 6422 v8::Handle<v8::String> data_1 = v8::String::New("1"); |
6426 context_1->SetData(data_1); | 6423 context_1->SetEmbedderData(0, data_1); |
6427 CHECK(context_1->GetData()->StrictEquals(data_1)); | 6424 CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1)); |
6428 | 6425 |
6429 // Simple test function with eval that causes a break. | 6426 // Simple test function with eval that causes a break. |
6430 const char* source = "function f() { eval('debugger;'); }"; | 6427 const char* source = "function f() { eval('debugger;'); }"; |
6431 | 6428 |
6432 // Enter and run function in the context. | 6429 // Enter and run function in the context. |
6433 { | 6430 { |
6434 v8::Context::Scope context_scope(context_1); | 6431 v8::Context::Scope context_scope(context_1); |
6435 expected_context = context_1; | 6432 expected_context = context_1; |
6436 expected_context_data = data_1; | 6433 expected_context_data = data_1; |
6437 v8::Local<v8::Function> f = CompileFunction(source, "f"); | 6434 v8::Local<v8::Function> f = CompileFunction(source, "f"); |
(...skipping 20 matching lines...) Expand all Loading... |
6458 | 6455 |
6459 | 6456 |
6460 static bool sent_eval = false; | 6457 static bool sent_eval = false; |
6461 static int break_count = 0; | 6458 static int break_count = 0; |
6462 static int continue_command_send_count = 0; | 6459 static int continue_command_send_count = 0; |
6463 // Check that the expected context is the one generating the debug event | 6460 // Check that the expected context is the one generating the debug event |
6464 // including the case of nested break event. | 6461 // including the case of nested break event. |
6465 static void DebugEvalContextCheckMessageHandler( | 6462 static void DebugEvalContextCheckMessageHandler( |
6466 const v8::Debug::Message& message) { | 6463 const v8::Debug::Message& message) { |
6467 CHECK(message.GetEventContext() == expected_context); | 6464 CHECK(message.GetEventContext() == expected_context); |
6468 CHECK(message.GetEventContext()->GetData()->StrictEquals( | 6465 CHECK(message.GetEventContext()->GetEmbedderData(0)->StrictEquals( |
6469 expected_context_data)); | 6466 expected_context_data)); |
6470 message_handler_hit_count++; | 6467 message_handler_hit_count++; |
6471 | 6468 |
6472 static char print_buffer[1000]; | 6469 static char print_buffer[1000]; |
6473 v8::String::Value json(message.GetJSON()); | 6470 v8::String::Value json(message.GetJSON()); |
6474 Utf16ToAscii(*json, json.length(), print_buffer); | 6471 Utf16ToAscii(*json, json.length(), print_buffer); |
6475 | 6472 |
6476 if (IsBreakEventMessage(print_buffer)) { | 6473 if (IsBreakEventMessage(print_buffer)) { |
6477 break_count++; | 6474 break_count++; |
6478 if (!sent_eval) { | 6475 if (!sent_eval) { |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7526 TEST(LiveEditDisabled) { | 7523 TEST(LiveEditDisabled) { |
7527 v8::internal::FLAG_allow_natives_syntax = true; | 7524 v8::internal::FLAG_allow_natives_syntax = true; |
7528 v8::HandleScope scope; | 7525 v8::HandleScope scope; |
7529 LocalContext context; | 7526 LocalContext context; |
7530 v8::Debug::SetLiveEditEnabled(false); | 7527 v8::Debug::SetLiveEditEnabled(false); |
7531 CompileRun("%LiveEditCompareStrings('', '')"); | 7528 CompileRun("%LiveEditCompareStrings('', '')"); |
7532 } | 7529 } |
7533 | 7530 |
7534 | 7531 |
7535 #endif // ENABLE_DEBUGGER_SUPPORT | 7532 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |