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 4845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4856 // We match the message wether it is an evaluate response message. | 4856 // We match the message wether it is an evaluate response message. |
4857 bool IsEvaluateResponseMessage(char* message) { | 4857 bool IsEvaluateResponseMessage(char* message) { |
4858 const char* type_response = "\"type\":\"response\""; | 4858 const char* type_response = "\"type\":\"response\""; |
4859 const char* command_evaluate = "\"command\":\"evaluate\""; | 4859 const char* command_evaluate = "\"command\":\"evaluate\""; |
4860 // Does the message contain both type:response and command:evaluate? | 4860 // Does the message contain both type:response and command:evaluate? |
4861 return strstr(message, type_response) != NULL && | 4861 return strstr(message, type_response) != NULL && |
4862 strstr(message, command_evaluate) != NULL; | 4862 strstr(message, command_evaluate) != NULL; |
4863 } | 4863 } |
4864 | 4864 |
4865 | 4865 |
| 4866 // We match parts of the message to decide if it is a after compile message. |
| 4867 bool IsCompileEventMessage(char* message) { |
| 4868 const char* type_event = "\"type\":\"event\""; |
| 4869 const char* event_after_compile = "\"event\":\"afterCompile\""; |
| 4870 const char* event_compile_error = "\"event\":\"compileError\""; |
| 4871 // Does the message contain both type:event and event:afterCompile or |
| 4872 // event:compileError ? |
| 4873 return strstr(message, type_event) != NULL && |
| 4874 (strstr(message, event_after_compile) != NULL || |
| 4875 strstr(message, event_compile_error) != NULL); |
| 4876 } |
| 4877 |
| 4878 |
4866 static int StringToInt(const char* s) { | 4879 static int StringToInt(const char* s) { |
4867 return atoi(s); // NOLINT | 4880 return atoi(s); // NOLINT |
4868 } | 4881 } |
4869 | 4882 |
4870 | 4883 |
4871 // We match parts of the message to get evaluate result int value. | 4884 // We match parts of the message to get evaluate result int value. |
4872 int GetEvaluateIntResult(char *message) { | 4885 int GetEvaluateIntResult(char *message) { |
4873 const char* value = "\"value\":"; | 4886 const char* value = "\"value\":"; |
4874 char* pos = strstr(message, value); | 4887 char* pos = strstr(message, value); |
4875 if (pos == NULL) { | 4888 if (pos == NULL) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4939 | 4952 |
4940 static void MessageHandler(const v8::Debug::Message& message) { | 4953 static void MessageHandler(const v8::Debug::Message& message) { |
4941 v8::Handle<v8::String> json = message.GetJSON(); | 4954 v8::Handle<v8::String> json = message.GetJSON(); |
4942 v8::String::Utf8Value utf8(json); | 4955 v8::String::Utf8Value utf8(json); |
4943 if (IsBreakEventMessage(*utf8)) { | 4956 if (IsBreakEventMessage(*utf8)) { |
4944 // Lets test script wait until break occurs to send commands. | 4957 // Lets test script wait until break occurs to send commands. |
4945 // Signals when a break is reported. | 4958 // Signals when a break is reported. |
4946 message_queue_barriers.semaphore_2.Signal(); | 4959 message_queue_barriers.semaphore_2.Signal(); |
4947 } | 4960 } |
4948 | 4961 |
| 4962 if (IsCompileEventMessage(*utf8)) return; |
| 4963 |
4949 // Allow message handler to block on a semaphore, to test queueing of | 4964 // Allow message handler to block on a semaphore, to test queueing of |
4950 // messages while blocked. | 4965 // messages while blocked. |
4951 message_queue_barriers.semaphore_1.Wait(); | 4966 message_queue_barriers.semaphore_1.Wait(); |
4952 } | 4967 } |
4953 | 4968 |
4954 | 4969 |
4955 void MessageQueueDebuggerThread::Run() { | 4970 void MessageQueueDebuggerThread::Run() { |
4956 const int kBufferSize = 1000; | 4971 const int kBufferSize = 1000; |
4957 uint16_t buffer_1[kBufferSize]; | 4972 uint16_t buffer_1[kBufferSize]; |
4958 uint16_t buffer_2[kBufferSize]; | 4973 uint16_t buffer_2[kBufferSize]; |
(...skipping 2628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7587 env->Global()->Set(v8_str("fun"), fun->GetFunction()); | 7602 env->Global()->Set(v8_str("fun"), fun->GetFunction()); |
7588 | 7603 |
7589 CompileRun("var p = new Promise(function(res, rej) { fun(); res(); });"); | 7604 CompileRun("var p = new Promise(function(res, rej) { fun(); res(); });"); |
7590 CompileRun( | 7605 CompileRun( |
7591 "var r;" | 7606 "var r;" |
7592 "p.chain(function() { r = 'resolved'; }," | 7607 "p.chain(function() { r = 'resolved'; }," |
7593 " function(e) { r = 'rejected' + e; });"); | 7608 " function(e) { r = 'rejected' + e; });"); |
7594 CHECK(CompileRun("r")->Equals(v8_str("rejectedrejection"))); | 7609 CHECK(CompileRun("r")->Equals(v8_str("rejectedrejection"))); |
7595 CHECK_EQ(1, exception_event_counter); | 7610 CHECK_EQ(1, exception_event_counter); |
7596 } | 7611 } |
OLD | NEW |