OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 using ::v8::internal::EmbeddedVector; | 39 using ::v8::internal::EmbeddedVector; |
40 using ::v8::internal::Object; | 40 using ::v8::internal::Object; |
41 using ::v8::internal::OS; | 41 using ::v8::internal::OS; |
42 using ::v8::internal::Handle; | 42 using ::v8::internal::Handle; |
43 using ::v8::internal::Heap; | 43 using ::v8::internal::Heap; |
44 using ::v8::internal::JSGlobalProxy; | 44 using ::v8::internal::JSGlobalProxy; |
45 using ::v8::internal::Code; | 45 using ::v8::internal::Code; |
46 using ::v8::internal::Debug; | 46 using ::v8::internal::Debug; |
47 using ::v8::internal::Debugger; | 47 using ::v8::internal::Debugger; |
48 using ::v8::internal::Message; | 48 using ::v8::internal::CommandMessage; |
49 using ::v8::internal::MessageQueue; | 49 using ::v8::internal::CommandMessageQueue; |
50 using ::v8::internal::StepAction; | 50 using ::v8::internal::StepAction; |
51 using ::v8::internal::StepIn; // From StepAction enum | 51 using ::v8::internal::StepIn; // From StepAction enum |
52 using ::v8::internal::StepNext; // From StepAction enum | 52 using ::v8::internal::StepNext; // From StepAction enum |
53 using ::v8::internal::StepOut; // From StepAction enum | 53 using ::v8::internal::StepOut; // From StepAction enum |
54 using ::v8::internal::Vector; | 54 using ::v8::internal::Vector; |
55 | 55 |
56 | 56 |
57 // Size of temp buffer for formatting small strings. | 57 // Size of temp buffer for formatting small strings. |
58 #define SMALL_STRING_BUFFER_SIZE 80 | 58 #define SMALL_STRING_BUFFER_SIZE 80 |
59 | 59 |
(...skipping 3492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3552 | 3552 |
3553 int TestClientData::constructor_call_counter = 0; | 3553 int TestClientData::constructor_call_counter = 0; |
3554 int TestClientData::destructor_call_counter = 0; | 3554 int TestClientData::destructor_call_counter = 0; |
3555 | 3555 |
3556 | 3556 |
3557 // Tests that MessageQueue doesn't destroy client data when expands and | 3557 // Tests that MessageQueue doesn't destroy client data when expands and |
3558 // does destroy when it dies. | 3558 // does destroy when it dies. |
3559 TEST(MessageQueueExpandAndDestroy) { | 3559 TEST(MessageQueueExpandAndDestroy) { |
3560 TestClientData::ResetCounters(); | 3560 TestClientData::ResetCounters(); |
3561 { // Create a scope for the queue. | 3561 { // Create a scope for the queue. |
3562 MessageQueue queue(1); | 3562 CommandMessageQueue queue(1); |
3563 queue.Put(Message::NewCommand(Vector<uint16_t>::empty(), | 3563 queue.Put(CommandMessage::New(Vector<uint16_t>::empty(), |
3564 new TestClientData())); | 3564 new TestClientData())); |
3565 queue.Put(Message::NewCommand(Vector<uint16_t>::empty(), | 3565 queue.Put(CommandMessage::New(Vector<uint16_t>::empty(), |
3566 new TestClientData())); | 3566 new TestClientData())); |
3567 queue.Put(Message::NewCommand(Vector<uint16_t>::empty(), | 3567 queue.Put(CommandMessage::New(Vector<uint16_t>::empty(), |
3568 new TestClientData())); | 3568 new TestClientData())); |
3569 ASSERT_EQ(0, TestClientData::destructor_call_counter); | 3569 ASSERT_EQ(0, TestClientData::destructor_call_counter); |
3570 queue.Get().Dispose(); | 3570 queue.Get().Dispose(); |
3571 ASSERT_EQ(1, TestClientData::destructor_call_counter); | 3571 ASSERT_EQ(1, TestClientData::destructor_call_counter); |
3572 queue.Put(Message::NewCommand(Vector<uint16_t>::empty(), | 3572 queue.Put(CommandMessage::New(Vector<uint16_t>::empty(), |
3573 new TestClientData())); | 3573 new TestClientData())); |
3574 queue.Put(Message::NewCommand(Vector<uint16_t>::empty(), | 3574 queue.Put(CommandMessage::New(Vector<uint16_t>::empty(), |
3575 new TestClientData())); | 3575 new TestClientData())); |
3576 queue.Put(Message::NewCommand(Vector<uint16_t>::empty(), | 3576 queue.Put(CommandMessage::New(Vector<uint16_t>::empty(), |
3577 new TestClientData())); | 3577 new TestClientData())); |
3578 queue.Put(Message::NewOutput(v8::Handle<v8::String>(), | 3578 queue.Put(CommandMessage::New(Vector<uint16_t>::empty(), |
3579 new TestClientData())); | 3579 new TestClientData())); |
3580 queue.Put(Message::NewEmptyMessage()); | 3580 queue.Put(CommandMessage::New(Vector<uint16_t>::empty(), |
| 3581 new TestClientData())); |
3581 ASSERT_EQ(1, TestClientData::destructor_call_counter); | 3582 ASSERT_EQ(1, TestClientData::destructor_call_counter); |
3582 queue.Get().Dispose(); | 3583 queue.Get().Dispose(); |
3583 ASSERT_EQ(2, TestClientData::destructor_call_counter); | 3584 ASSERT_EQ(2, TestClientData::destructor_call_counter); |
3584 } | 3585 } |
3585 // All the client data should be destroyed when the queue is destroyed. | 3586 // All the client data should be destroyed when the queue is destroyed. |
3586 ASSERT_EQ(TestClientData::destructor_call_counter, | 3587 ASSERT_EQ(TestClientData::destructor_call_counter, |
3587 TestClientData::destructor_call_counter); | 3588 TestClientData::destructor_call_counter); |
3588 } | 3589 } |
3589 | 3590 |
3590 | 3591 |
3591 static int handled_client_data_instances_count = 0; | 3592 static int handled_client_data_instances_count = 0; |
3592 static void MessageHandlerCountingClientData( | 3593 static void MessageHandlerCountingClientData( |
3593 const uint16_t* message, | 3594 const uint16_t* message, |
3594 int length, | 3595 int length, |
3595 v8::Debug::ClientData* client_data) { | 3596 v8::Debug::ClientData* client_data) { |
3596 if (client_data) { | 3597 if (client_data) { |
3597 handled_client_data_instances_count++; | 3598 handled_client_data_instances_count++; |
3598 } | 3599 } |
3599 } | 3600 } |
3600 | 3601 |
3601 | 3602 |
3602 // Tests that all client data passed to the debugger are sent to the handler. | 3603 // Tests that all client data passed to the debugger are sent to the handler. |
3603 TEST(SendClientDataToHandler) { | 3604 TEST(SendClientDataToHandler) { |
3604 // Create a V8 environment | 3605 // Create a V8 environment |
3605 v8::HandleScope scope; | 3606 v8::HandleScope scope; |
3606 DebugLocalContext env; | 3607 DebugLocalContext env; |
3607 TestClientData::ResetCounters(); | 3608 TestClientData::ResetCounters(); |
3608 handled_client_data_instances_count = 0; | 3609 handled_client_data_instances_count = 0; |
3609 v8::Debug::SetMessageHandler(MessageHandlerCountingClientData, | 3610 v8::Debug::SetMessageHandler(MessageHandlerCountingClientData); |
3610 false /* message_handler_thread */); | |
3611 const char* source_1 = "a = 3; b = 4; c = new Object(); c.d = 5; debugger;"; | 3611 const char* source_1 = "a = 3; b = 4; c = new Object(); c.d = 5; debugger;"; |
3612 const int kBufferSize = 1000; | 3612 const int kBufferSize = 1000; |
3613 uint16_t buffer[kBufferSize]; | 3613 uint16_t buffer[kBufferSize]; |
3614 const char* command_1 = | 3614 const char* command_1 = |
3615 "{\"seq\":117," | 3615 "{\"seq\":117," |
3616 "\"type\":\"request\"," | 3616 "\"type\":\"request\"," |
3617 "\"command\":\"evaluate\"," | 3617 "\"command\":\"evaluate\"," |
3618 "\"arguments\":{\"expression\":\"1+2\"}}"; | 3618 "\"arguments\":{\"expression\":\"1+2\"}}"; |
3619 const char* command_2 = | 3619 const char* command_2 = |
3620 "{\"seq\":118," | 3620 "{\"seq\":118," |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4569 v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name")); | 4569 v8::ScriptOrigin origin2 = v8::ScriptOrigin(v8::String::New("new name")); |
4570 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); | 4570 v8::Handle<v8::Script> script2 = v8::Script::Compile(script, &origin2); |
4571 script2->Run(); | 4571 script2->Run(); |
4572 script2->SetData(data_obj); | 4572 script2->SetData(data_obj); |
4573 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 4573 f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); |
4574 f->Call(env->Global(), 0, NULL); | 4574 f->Call(env->Global(), 0, NULL); |
4575 CHECK_EQ(2, break_point_hit_count); | 4575 CHECK_EQ(2, break_point_hit_count); |
4576 CHECK_EQ("new name", last_script_name_hit); | 4576 CHECK_EQ("new name", last_script_name_hit); |
4577 CHECK_EQ("abc 123", last_script_data_hit); | 4577 CHECK_EQ("abc 123", last_script_data_hit); |
4578 } | 4578 } |
OLD | NEW |