OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/inspector/v8-console.h" | 5 #include "src/inspector/v8-console.h" |
6 | 6 |
7 #include "src/base/macros.h" | 7 #include "src/base/macros.h" |
8 #include "src/inspector/injected-script.h" | 8 #include "src/inspector/injected-script.h" |
9 #include "src/inspector/inspected-context.h" | 9 #include "src/inspector/inspected-context.h" |
10 #include "src/inspector/string-util.h" | 10 #include "src/inspector/string-util.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 void reportDeprecatedCall(const char* id, const String16& message) { | 82 void reportDeprecatedCall(const char* id, const String16& message) { |
83 if (!consoleMessageStorage()->shouldReportDeprecationMessage(m_contextId, | 83 if (!consoleMessageStorage()->shouldReportDeprecationMessage(m_contextId, |
84 id)) { | 84 id)) { |
85 return; | 85 return; |
86 } | 86 } |
87 std::vector<v8::Local<v8::Value>> arguments(1, | 87 std::vector<v8::Local<v8::Value>> arguments(1, |
88 toV8String(m_isolate, message)); | 88 toV8String(m_isolate, message)); |
89 reportCall(ConsoleAPIType::kWarning, arguments); | 89 reportCall(ConsoleAPIType::kWarning, arguments); |
90 } | 90 } |
91 | 91 |
92 bool firstArgToBoolean(bool defaultValue) { | |
93 if (m_info.Length() < 1) return defaultValue; | |
94 if (m_info[0]->IsBoolean()) return m_info[0].As<v8::Boolean>()->Value(); | |
95 return m_info[0]->BooleanValue(m_context).FromMaybe(defaultValue); | |
96 } | |
97 | |
98 String16 firstArgToString(const String16& defaultValue) { | 92 String16 firstArgToString(const String16& defaultValue) { |
99 if (m_info.Length() < 1) return defaultValue; | 93 if (m_info.Length() < 1) return defaultValue; |
100 v8::Local<v8::String> titleValue; | 94 v8::Local<v8::String> titleValue; |
101 if (m_info[0]->IsObject()) { | 95 if (m_info[0]->IsObject()) { |
102 if (!m_info[0].As<v8::Object>()->ObjectProtoToString(m_context).ToLocal( | 96 if (!m_info[0].As<v8::Object>()->ObjectProtoToString(m_context).ToLocal( |
103 &titleValue)) | 97 &titleValue)) |
104 return defaultValue; | 98 return defaultValue; |
105 } else { | 99 } else { |
106 if (!m_info[0]->ToString(m_context).ToLocal(&titleValue)) | 100 if (!m_info[0]->ToString(m_context).ToLocal(&titleValue)) |
107 return defaultValue; | 101 return defaultValue; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 } | 264 } |
271 | 265 |
272 int count = | 266 int count = |
273 helper.consoleMessageStorage()->count(helper.contextId(), identifier); | 267 helper.consoleMessageStorage()->count(helper.contextId(), identifier); |
274 String16 countString = String16::fromInteger(count); | 268 String16 countString = String16::fromInteger(count); |
275 helper.reportCallWithArgument( | 269 helper.reportCallWithArgument( |
276 ConsoleAPIType::kCount, | 270 ConsoleAPIType::kCount, |
277 title.isEmpty() ? countString : (title + ": " + countString)); | 271 title.isEmpty() ? countString : (title + ": " + countString)); |
278 } | 272 } |
279 | 273 |
280 void V8Console::Assert(const v8::debug::ConsoleCallArguments& info) { | 274 void V8Console::Assert(const v8::debug::ConsoleCallArguments& info) { |
Igor Sheludko
2017/04/20 10:18:42
Maybe ReportAssertionFailure or something similar
Igor Sheludko
2017/04/20 14:26:10
Given that we are passing all the arguments (inclu
kozy
2017/04/20 15:14:54
It would be cool to pass all arguments except firs
| |
281 ConsoleHelper helper(info, m_inspector); | 275 ConsoleHelper helper(info, m_inspector); |
Igor Sheludko
2017/04/20 10:18:42
or DCHECK(!helper.firstArgToBoolean(false));
kozy
2017/04/20 15:14:54
added DCHECK.
| |
282 if (helper.firstArgToBoolean(false)) return; | |
283 | 276 |
284 std::vector<v8::Local<v8::Value>> arguments; | 277 std::vector<v8::Local<v8::Value>> arguments; |
285 for (int i = 1; i < info.Length(); ++i) arguments.push_back(info[i]); | 278 for (int i = 1; i < info.Length(); ++i) arguments.push_back(info[i]); |
286 if (info.Length() < 2) | 279 if (info.Length() < 2) |
287 arguments.push_back( | 280 arguments.push_back( |
288 toV8String(m_inspector->isolate(), String16("console.assert"))); | 281 toV8String(m_inspector->isolate(), String16("console.assert"))); |
289 helper.reportCall(ConsoleAPIType::kAssert, arguments); | 282 helper.reportCall(ConsoleAPIType::kAssert, arguments); |
290 | 283 |
291 if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent()) | 284 if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent()) |
292 debuggerAgent->breakProgramOnException( | 285 debuggerAgent->breakProgramOnException( |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
751 ->GetOwnPropertyDescriptor( | 744 ->GetOwnPropertyDescriptor( |
752 m_context, v8::Local<v8::String>::Cast(name)) | 745 m_context, v8::Local<v8::String>::Cast(name)) |
753 .ToLocal(&descriptor); | 746 .ToLocal(&descriptor); |
754 DCHECK(success); | 747 DCHECK(success); |
755 USE(success); | 748 USE(success); |
756 } | 749 } |
757 } | 750 } |
758 } | 751 } |
759 | 752 |
760 } // namespace v8_inspector | 753 } // namespace v8_inspector |
OLD | NEW |