| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace v8_inspector { | 22 namespace v8_inspector { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 class ConsoleHelper { | 26 class ConsoleHelper { |
| 27 public: | 27 public: |
| 28 explicit ConsoleHelper(const v8::FunctionCallbackInfo<v8::Value>& info, | 28 explicit ConsoleHelper(const v8::FunctionCallbackInfo<v8::Value>& info, |
| 29 V8InspectorImpl* inspector) | 29 V8InspectorImpl* inspector) |
| 30 : m_info(info), | 30 : m_info(info), |
| 31 m_isolate(info.GetIsolate()), | 31 m_isolate(inspector->isolate()), |
| 32 m_context(info.GetIsolate()->GetCurrentContext()), | 32 m_context(m_isolate->GetCurrentContext()), |
| 33 m_inspector(inspector), | 33 m_inspector(inspector), |
| 34 m_contextId(InspectedContext::contextId(m_context)), | 34 m_contextId(InspectedContext::contextId(m_context)), |
| 35 m_groupId(m_inspector->contextGroupId(m_contextId)) {} | 35 m_groupId(m_inspector->contextGroupId(m_contextId)) {} |
| 36 | 36 |
| 37 int contextId() const { return m_contextId; } | 37 int contextId() const { return m_contextId; } |
| 38 int groupId() const { return m_groupId; } | 38 int groupId() const { return m_groupId; } |
| 39 | 39 |
| 40 InjectedScript* injectedScript() { | 40 InjectedScript* injectedScript() { |
| 41 InspectedContext* context = m_inspector->getContext(m_groupId, m_contextId); | 41 InspectedContext* context = m_inspector->getContext(m_groupId, m_contextId); |
| 42 if (!context) return nullptr; | 42 if (!context) return nullptr; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 context->GetIsolate(), "toString"), | 183 context->GetIsolate(), "toString"), |
| 184 toStringFunction); | 184 toStringFunction); |
| 185 } | 185 } |
| 186 createDataProperty(context, console, funcName, func); | 186 createDataProperty(context, console, funcName, func); |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace | 189 } // namespace |
| 190 | 190 |
| 191 V8Console::V8Console(V8InspectorImpl* inspector) : m_inspector(inspector) {} | 191 V8Console::V8Console(V8InspectorImpl* inspector) : m_inspector(inspector) {} |
| 192 | 192 |
| 193 void V8Console::debugCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 193 void V8Console::Debug(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 194 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDebug); | 194 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDebug); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void V8Console::errorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 197 void V8Console::Error(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 198 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kError); | 198 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kError); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void V8Console::infoCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 201 void V8Console::Info(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 202 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kInfo); | 202 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kInfo); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void V8Console::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 205 void V8Console::Log(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 206 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kLog); | 206 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kLog); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void V8Console::warnCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 209 void V8Console::Warn(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 210 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kWarning); | 210 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kWarning); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void V8Console::dirCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 213 void V8Console::Dir(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 214 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDir); | 214 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDir); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void V8Console::dirxmlCallback( | 217 void V8Console::DirXml(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 218 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 219 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDirXML); | 218 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDirXML); |
| 220 } | 219 } |
| 221 | 220 |
| 222 void V8Console::tableCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 221 void V8Console::Table(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 223 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kTable); | 222 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kTable); |
| 224 } | 223 } |
| 225 | 224 |
| 226 void V8Console::traceCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 225 void V8Console::Trace(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 227 ConsoleHelper(info, m_inspector) | 226 ConsoleHelper(info, m_inspector) |
| 228 .reportCallWithDefaultArgument(ConsoleAPIType::kTrace, | 227 .reportCallWithDefaultArgument(ConsoleAPIType::kTrace, |
| 229 String16("console.trace")); | 228 String16("console.trace")); |
| 230 } | 229 } |
| 231 | 230 |
| 232 void V8Console::groupCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 231 void V8Console::Group(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 233 ConsoleHelper(info, m_inspector) | 232 ConsoleHelper(info, m_inspector) |
| 234 .reportCallWithDefaultArgument(ConsoleAPIType::kStartGroup, | 233 .reportCallWithDefaultArgument(ConsoleAPIType::kStartGroup, |
| 235 String16("console.group")); | 234 String16("console.group")); |
| 236 } | 235 } |
| 237 | 236 |
| 238 void V8Console::groupCollapsedCallback( | 237 void V8Console::GroupCollapsed( |
| 239 const v8::FunctionCallbackInfo<v8::Value>& info) { | 238 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 240 ConsoleHelper(info, m_inspector) | 239 ConsoleHelper(info, m_inspector) |
| 241 .reportCallWithDefaultArgument(ConsoleAPIType::kStartGroupCollapsed, | 240 .reportCallWithDefaultArgument(ConsoleAPIType::kStartGroupCollapsed, |
| 242 String16("console.groupCollapsed")); | 241 String16("console.groupCollapsed")); |
| 243 } | 242 } |
| 244 | 243 |
| 245 void V8Console::groupEndCallback( | 244 void V8Console::GroupEnd(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 246 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 247 ConsoleHelper(info, m_inspector) | 245 ConsoleHelper(info, m_inspector) |
| 248 .reportCallWithDefaultArgument(ConsoleAPIType::kEndGroup, | 246 .reportCallWithDefaultArgument(ConsoleAPIType::kEndGroup, |
| 249 String16("console.groupEnd")); | 247 String16("console.groupEnd")); |
| 250 } | 248 } |
| 251 | 249 |
| 252 void V8Console::clearCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 250 void V8Console::Clear(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 253 ConsoleHelper helper(info, m_inspector); | 251 ConsoleHelper helper(info, m_inspector); |
| 254 if (!helper.groupId()) return; | 252 if (!helper.groupId()) return; |
| 255 m_inspector->client()->consoleClear(helper.groupId()); | 253 m_inspector->client()->consoleClear(helper.groupId()); |
| 256 helper.reportCallWithDefaultArgument(ConsoleAPIType::kClear, | 254 helper.reportCallWithDefaultArgument(ConsoleAPIType::kClear, |
| 257 String16("console.clear")); | 255 String16("console.clear")); |
| 258 } | 256 } |
| 259 | 257 |
| 260 void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 258 void V8Console::Count(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 261 ConsoleHelper helper(info, m_inspector); | 259 ConsoleHelper helper(info, m_inspector); |
| 262 String16 title = helper.firstArgToString(String16()); | 260 String16 title = helper.firstArgToString(String16()); |
| 263 String16 identifier; | 261 String16 identifier; |
| 264 if (title.isEmpty()) { | 262 if (title.isEmpty()) { |
| 265 std::unique_ptr<V8StackTraceImpl> stackTrace = | 263 std::unique_ptr<V8StackTraceImpl> stackTrace = |
| 266 V8StackTraceImpl::capture(m_inspector->debugger(), 0, 1); | 264 V8StackTraceImpl::capture(m_inspector->debugger(), 0, 1); |
| 267 if (stackTrace && !stackTrace->isEmpty()) { | 265 if (stackTrace && !stackTrace->isEmpty()) { |
| 268 identifier = toString16(stackTrace->topSourceURL()) + ":" + | 266 identifier = toString16(stackTrace->topSourceURL()) + ":" + |
| 269 String16::fromInteger(stackTrace->topLineNumber()); | 267 String16::fromInteger(stackTrace->topLineNumber()); |
| 270 } | 268 } |
| 271 } else { | 269 } else { |
| 272 identifier = title + "@"; | 270 identifier = title + "@"; |
| 273 } | 271 } |
| 274 | 272 |
| 275 int count = | 273 int count = |
| 276 helper.consoleMessageStorage()->count(helper.contextId(), identifier); | 274 helper.consoleMessageStorage()->count(helper.contextId(), identifier); |
| 277 String16 countString = String16::fromInteger(count); | 275 String16 countString = String16::fromInteger(count); |
| 278 helper.reportCallWithArgument( | 276 helper.reportCallWithArgument( |
| 279 ConsoleAPIType::kCount, | 277 ConsoleAPIType::kCount, |
| 280 title.isEmpty() ? countString : (title + ": " + countString)); | 278 title.isEmpty() ? countString : (title + ": " + countString)); |
| 281 } | 279 } |
| 282 | 280 |
| 283 void V8Console::assertCallback( | 281 void V8Console::Assert(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 284 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 285 ConsoleHelper helper(info, m_inspector); | 282 ConsoleHelper helper(info, m_inspector); |
| 286 if (helper.firstArgToBoolean(false)) return; | 283 if (helper.firstArgToBoolean(false)) return; |
| 287 | 284 |
| 288 std::vector<v8::Local<v8::Value>> arguments; | 285 std::vector<v8::Local<v8::Value>> arguments; |
| 289 for (int i = 1; i < info.Length(); ++i) arguments.push_back(info[i]); | 286 for (int i = 1; i < info.Length(); ++i) arguments.push_back(info[i]); |
| 290 if (info.Length() < 2) | 287 if (info.Length() < 2) |
| 291 arguments.push_back( | 288 arguments.push_back( |
| 292 toV8String(info.GetIsolate(), String16("console.assert"))); | 289 toV8String(m_inspector->isolate(), String16("console.assert"))); |
| 293 helper.reportCall(ConsoleAPIType::kAssert, arguments); | 290 helper.reportCall(ConsoleAPIType::kAssert, arguments); |
| 294 | 291 |
| 295 if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent()) | 292 if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent()) |
| 296 debuggerAgent->breakProgramOnException( | 293 debuggerAgent->breakProgramOnException( |
| 297 protocol::Debugger::Paused::ReasonEnum::Assert, nullptr); | 294 protocol::Debugger::Paused::ReasonEnum::Assert, nullptr); |
| 298 } | 295 } |
| 299 | 296 |
| 300 void V8Console::markTimelineCallback( | 297 void V8Console::MarkTimeline(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 301 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 302 ConsoleHelper(info, m_inspector) | 298 ConsoleHelper(info, m_inspector) |
| 303 .reportDeprecatedCall("V8Console#markTimelineDeprecated", | 299 .reportDeprecatedCall("V8Console#markTimelineDeprecated", |
| 304 "'console.markTimeline' is " | 300 "'console.markTimeline' is " |
| 305 "deprecated. Please use " | 301 "deprecated. Please use " |
| 306 "'console.timeStamp' instead."); | 302 "'console.timeStamp' instead."); |
| 307 timeStampCallback(info); | 303 TimeStamp(info); |
| 308 } | 304 } |
| 309 | 305 |
| 310 void V8Console::profileCallback( | 306 void V8Console::Profile(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 311 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 312 ConsoleHelper helper(info, m_inspector); | 307 ConsoleHelper helper(info, m_inspector); |
| 313 if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent()) | 308 if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent()) |
| 314 profilerAgent->consoleProfile(helper.firstArgToString(String16())); | 309 profilerAgent->consoleProfile(helper.firstArgToString(String16())); |
| 315 } | 310 } |
| 316 | 311 |
| 317 void V8Console::profileEndCallback( | 312 void V8Console::ProfileEnd(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 318 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 319 ConsoleHelper helper(info, m_inspector); | 313 ConsoleHelper helper(info, m_inspector); |
| 320 if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent()) | 314 if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent()) |
| 321 profilerAgent->consoleProfileEnd(helper.firstArgToString(String16())); | 315 profilerAgent->consoleProfileEnd(helper.firstArgToString(String16())); |
| 322 } | 316 } |
| 323 | 317 |
| 324 static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info, | 318 static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info, |
| 325 bool timelinePrefix, V8InspectorImpl* inspector) { | 319 bool timelinePrefix, V8InspectorImpl* inspector) { |
| 326 ConsoleHelper helper(info, inspector); | 320 ConsoleHelper helper(info, inspector); |
| 327 String16 protocolTitle = helper.firstArgToString("default"); | 321 String16 protocolTitle = helper.firstArgToString("default"); |
| 328 if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'"; | 322 if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'"; |
| 329 inspector->client()->consoleTime(toStringView(protocolTitle)); | 323 inspector->client()->consoleTime(toStringView(protocolTitle)); |
| 330 helper.consoleMessageStorage()->time(helper.contextId(), protocolTitle); | 324 helper.consoleMessageStorage()->time(helper.contextId(), protocolTitle); |
| 331 } | 325 } |
| 332 | 326 |
| 333 static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info, | 327 static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info, |
| 334 bool timelinePrefix, V8InspectorImpl* inspector) { | 328 bool timelinePrefix, V8InspectorImpl* inspector) { |
| 335 ConsoleHelper helper(info, inspector); | 329 ConsoleHelper helper(info, inspector); |
| 336 String16 protocolTitle = helper.firstArgToString("default"); | 330 String16 protocolTitle = helper.firstArgToString("default"); |
| 337 if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'"; | 331 if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'"; |
| 338 inspector->client()->consoleTimeEnd(toStringView(protocolTitle)); | 332 inspector->client()->consoleTimeEnd(toStringView(protocolTitle)); |
| 339 double elapsed = helper.consoleMessageStorage()->timeEnd(helper.contextId(), | 333 double elapsed = helper.consoleMessageStorage()->timeEnd(helper.contextId(), |
| 340 protocolTitle); | 334 protocolTitle); |
| 341 String16 message = | 335 String16 message = |
| 342 protocolTitle + ": " + String16::fromDouble(elapsed) + "ms"; | 336 protocolTitle + ": " + String16::fromDouble(elapsed) + "ms"; |
| 343 helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message); | 337 helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message); |
| 344 } | 338 } |
| 345 | 339 |
| 346 void V8Console::timelineCallback( | 340 void V8Console::Timeline(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 347 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 348 ConsoleHelper(info, m_inspector) | 341 ConsoleHelper(info, m_inspector) |
| 349 .reportDeprecatedCall("V8Console#timeline", | 342 .reportDeprecatedCall("V8Console#timeline", |
| 350 "'console.timeline' is deprecated. Please use " | 343 "'console.timeline' is deprecated. Please use " |
| 351 "'console.time' instead."); | 344 "'console.time' instead."); |
| 352 timeFunction(info, true, m_inspector); | 345 timeFunction(info, true, m_inspector); |
| 353 } | 346 } |
| 354 | 347 |
| 355 void V8Console::timelineEndCallback( | 348 void V8Console::TimelineEnd(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 356 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 357 ConsoleHelper(info, m_inspector) | 349 ConsoleHelper(info, m_inspector) |
| 358 .reportDeprecatedCall("V8Console#timelineEnd", | 350 .reportDeprecatedCall("V8Console#timelineEnd", |
| 359 "'console.timelineEnd' is " | 351 "'console.timelineEnd' is " |
| 360 "deprecated. Please use " | 352 "deprecated. Please use " |
| 361 "'console.timeEnd' instead."); | 353 "'console.timeEnd' instead."); |
| 362 timeEndFunction(info, true, m_inspector); | 354 timeEndFunction(info, true, m_inspector); |
| 363 } | 355 } |
| 364 | 356 |
| 365 void V8Console::timeCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { | 357 void V8Console::Time(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 366 timeFunction(info, false, m_inspector); | 358 timeFunction(info, false, m_inspector); |
| 367 } | 359 } |
| 368 | 360 |
| 369 void V8Console::timeEndCallback( | 361 void V8Console::TimeEnd(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 370 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 371 timeEndFunction(info, false, m_inspector); | 362 timeEndFunction(info, false, m_inspector); |
| 372 } | 363 } |
| 373 | 364 |
| 374 void V8Console::timeStampCallback( | 365 void V8Console::TimeStamp(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 375 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 376 ConsoleHelper helper(info, m_inspector); | 366 ConsoleHelper helper(info, m_inspector); |
| 377 String16 title = helper.firstArgToString(String16()); | 367 String16 title = helper.firstArgToString(String16()); |
| 378 m_inspector->client()->consoleTimeStamp(toStringView(title)); | 368 m_inspector->client()->consoleTimeStamp(toStringView(title)); |
| 379 } | 369 } |
| 380 | 370 |
| 381 void V8Console::memoryGetterCallback( | 371 void V8Console::memoryGetterCallback( |
| 382 const v8::FunctionCallbackInfo<v8::Value>& info) { | 372 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 383 v8::Local<v8::Value> memoryValue; | 373 v8::Local<v8::Value> memoryValue; |
| 384 if (!m_inspector->client() | 374 if (!m_inspector->client() |
| 385 ->memoryInfo(info.GetIsolate(), | 375 ->memoryInfo(info.GetIsolate(), |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 if (V8InspectorSessionImpl* session = helper.currentSession()) { | 541 if (V8InspectorSessionImpl* session = helper.currentSession()) { |
| 552 V8InspectorSession::Inspectable* object = session->inspectedObject(num); | 542 V8InspectorSession::Inspectable* object = session->inspectedObject(num); |
| 553 v8::Isolate* isolate = info.GetIsolate(); | 543 v8::Isolate* isolate = info.GetIsolate(); |
| 554 if (object) | 544 if (object) |
| 555 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext())); | 545 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext())); |
| 556 else | 546 else |
| 557 info.GetReturnValue().Set(v8::Undefined(isolate)); | 547 info.GetReturnValue().Set(v8::Undefined(isolate)); |
| 558 } | 548 } |
| 559 } | 549 } |
| 560 | 550 |
| 561 v8::Local<v8::Object> V8Console::createConsole(v8::Local<v8::Context> context) { | |
| 562 v8::Context::Scope contextScope(context); | |
| 563 v8::Isolate* isolate = context->GetIsolate(); | |
| 564 v8::MicrotasksScope microtasksScope(isolate, | |
| 565 v8::MicrotasksScope::kDoNotRunMicrotasks); | |
| 566 | |
| 567 v8::Local<v8::Object> console = v8::Object::New(isolate); | |
| 568 bool success = | |
| 569 console->SetPrototype(context, v8::Object::New(isolate)).FromMaybe(false); | |
| 570 DCHECK(success); | |
| 571 USE(success); | |
| 572 | |
| 573 v8::Local<v8::External> data = v8::External::New(isolate, this); | |
| 574 createBoundFunctionProperty(context, console, data, "debug", | |
| 575 &V8Console::call<&V8Console::debugCallback>); | |
| 576 createBoundFunctionProperty(context, console, data, "error", | |
| 577 &V8Console::call<&V8Console::errorCallback>); | |
| 578 createBoundFunctionProperty(context, console, data, "info", | |
| 579 &V8Console::call<&V8Console::infoCallback>); | |
| 580 createBoundFunctionProperty(context, console, data, "log", | |
| 581 &V8Console::call<&V8Console::logCallback>); | |
| 582 createBoundFunctionProperty(context, console, data, "warn", | |
| 583 &V8Console::call<&V8Console::warnCallback>); | |
| 584 createBoundFunctionProperty(context, console, data, "dir", | |
| 585 &V8Console::call<&V8Console::dirCallback>); | |
| 586 createBoundFunctionProperty(context, console, data, "dirxml", | |
| 587 &V8Console::call<&V8Console::dirxmlCallback>); | |
| 588 createBoundFunctionProperty(context, console, data, "table", | |
| 589 &V8Console::call<&V8Console::tableCallback>); | |
| 590 createBoundFunctionProperty(context, console, data, "trace", | |
| 591 &V8Console::call<&V8Console::traceCallback>); | |
| 592 createBoundFunctionProperty(context, console, data, "group", | |
| 593 &V8Console::call<&V8Console::groupCallback>); | |
| 594 createBoundFunctionProperty( | |
| 595 context, console, data, "groupCollapsed", | |
| 596 &V8Console::call<&V8Console::groupCollapsedCallback>); | |
| 597 createBoundFunctionProperty(context, console, data, "groupEnd", | |
| 598 &V8Console::call<&V8Console::groupEndCallback>); | |
| 599 createBoundFunctionProperty(context, console, data, "clear", | |
| 600 &V8Console::call<&V8Console::clearCallback>); | |
| 601 createBoundFunctionProperty(context, console, data, "count", | |
| 602 &V8Console::call<&V8Console::countCallback>); | |
| 603 createBoundFunctionProperty(context, console, data, "assert", | |
| 604 &V8Console::call<&V8Console::assertCallback>); | |
| 605 createBoundFunctionProperty( | |
| 606 context, console, data, "markTimeline", | |
| 607 &V8Console::call<&V8Console::markTimelineCallback>); | |
| 608 createBoundFunctionProperty(context, console, data, "profile", | |
| 609 &V8Console::call<&V8Console::profileCallback>); | |
| 610 createBoundFunctionProperty(context, console, data, "profileEnd", | |
| 611 &V8Console::call<&V8Console::profileEndCallback>); | |
| 612 createBoundFunctionProperty(context, console, data, "timeline", | |
| 613 &V8Console::call<&V8Console::timelineCallback>); | |
| 614 createBoundFunctionProperty( | |
| 615 context, console, data, "timelineEnd", | |
| 616 &V8Console::call<&V8Console::timelineEndCallback>); | |
| 617 createBoundFunctionProperty(context, console, data, "time", | |
| 618 &V8Console::call<&V8Console::timeCallback>); | |
| 619 createBoundFunctionProperty(context, console, data, "timeEnd", | |
| 620 &V8Console::call<&V8Console::timeEndCallback>); | |
| 621 createBoundFunctionProperty(context, console, data, "timeStamp", | |
| 622 &V8Console::call<&V8Console::timeStampCallback>); | |
| 623 return console; | |
| 624 } | |
| 625 | |
| 626 void V8Console::installMemoryGetter(v8::Local<v8::Context> context, | 551 void V8Console::installMemoryGetter(v8::Local<v8::Context> context, |
| 627 v8::Local<v8::Object> console) { | 552 v8::Local<v8::Object> console) { |
| 628 v8::Isolate* isolate = context->GetIsolate(); | 553 v8::Isolate* isolate = context->GetIsolate(); |
| 629 v8::Local<v8::External> data = v8::External::New(isolate, this); | 554 v8::Local<v8::External> data = v8::External::New(isolate, this); |
| 630 console->SetAccessorProperty( | 555 console->SetAccessorProperty( |
| 631 toV8StringInternalized(isolate, "memory"), | 556 toV8StringInternalized(isolate, "memory"), |
| 632 v8::Function::New(context, | 557 v8::Function::New(context, |
| 633 &V8Console::call<&V8Console::memoryGetterCallback>, | 558 &V8Console::call<&V8Console::memoryGetterCallback>, |
| 634 data, 0, v8::ConstructorBehavior::kThrow) | 559 data, 0, v8::ConstructorBehavior::kThrow) |
| 635 .ToLocalChecked(), | 560 .ToLocalChecked(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 647 v8::MicrotasksScope::kDoNotRunMicrotasks); | 572 v8::MicrotasksScope::kDoNotRunMicrotasks); |
| 648 | 573 |
| 649 v8::Local<v8::Object> commandLineAPI = v8::Object::New(isolate); | 574 v8::Local<v8::Object> commandLineAPI = v8::Object::New(isolate); |
| 650 bool success = | 575 bool success = |
| 651 commandLineAPI->SetPrototype(context, v8::Null(isolate)).FromMaybe(false); | 576 commandLineAPI->SetPrototype(context, v8::Null(isolate)).FromMaybe(false); |
| 652 DCHECK(success); | 577 DCHECK(success); |
| 653 USE(success); | 578 USE(success); |
| 654 | 579 |
| 655 v8::Local<v8::External> data = v8::External::New(isolate, this); | 580 v8::Local<v8::External> data = v8::External::New(isolate, this); |
| 656 createBoundFunctionProperty(context, commandLineAPI, data, "dir", | 581 createBoundFunctionProperty(context, commandLineAPI, data, "dir", |
| 657 &V8Console::call<&V8Console::dirCallback>, | 582 &V8Console::call<&V8Console::Dir>, |
| 658 "function dir(value) { [Command Line API] }"); | 583 "function dir(value) { [Command Line API] }"); |
| 659 createBoundFunctionProperty(context, commandLineAPI, data, "dirxml", | 584 createBoundFunctionProperty(context, commandLineAPI, data, "dirxml", |
| 660 &V8Console::call<&V8Console::dirxmlCallback>, | 585 &V8Console::call<&V8Console::DirXml>, |
| 661 "function dirxml(value) { [Command Line API] }"); | 586 "function dirxml(value) { [Command Line API] }"); |
| 662 createBoundFunctionProperty(context, commandLineAPI, data, "profile", | 587 createBoundFunctionProperty(context, commandLineAPI, data, "profile", |
| 663 &V8Console::call<&V8Console::profileCallback>, | 588 &V8Console::call<&V8Console::Profile>, |
| 664 "function profile(title) { [Command Line API] }"); | 589 "function profile(title) { [Command Line API] }"); |
| 665 createBoundFunctionProperty( | 590 createBoundFunctionProperty( |
| 666 context, commandLineAPI, data, "profileEnd", | 591 context, commandLineAPI, data, "profileEnd", |
| 667 &V8Console::call<&V8Console::profileEndCallback>, | 592 &V8Console::call<&V8Console::ProfileEnd>, |
| 668 "function profileEnd(title) { [Command Line API] }"); | 593 "function profileEnd(title) { [Command Line API] }"); |
| 669 createBoundFunctionProperty(context, commandLineAPI, data, "clear", | 594 createBoundFunctionProperty(context, commandLineAPI, data, "clear", |
| 670 &V8Console::call<&V8Console::clearCallback>, | 595 &V8Console::call<&V8Console::Clear>, |
| 671 "function clear() { [Command Line API] }"); | 596 "function clear() { [Command Line API] }"); |
| 672 createBoundFunctionProperty( | 597 createBoundFunctionProperty( |
| 673 context, commandLineAPI, data, "table", | 598 context, commandLineAPI, data, "table", |
| 674 &V8Console::call<&V8Console::tableCallback>, | 599 &V8Console::call<&V8Console::Table>, |
| 675 "function table(data, [columns]) { [Command Line API] }"); | 600 "function table(data, [columns]) { [Command Line API] }"); |
| 676 | 601 |
| 677 createBoundFunctionProperty(context, commandLineAPI, data, "keys", | 602 createBoundFunctionProperty(context, commandLineAPI, data, "keys", |
| 678 &V8Console::call<&V8Console::keysCallback>, | 603 &V8Console::call<&V8Console::keysCallback>, |
| 679 "function keys(object) { [Command Line API] }"); | 604 "function keys(object) { [Command Line API] }"); |
| 680 createBoundFunctionProperty(context, commandLineAPI, data, "values", | 605 createBoundFunctionProperty(context, commandLineAPI, data, "values", |
| 681 &V8Console::call<&V8Console::valuesCallback>, | 606 &V8Console::call<&V8Console::valuesCallback>, |
| 682 "function values(object) { [Command Line API] }"); | 607 "function values(object) { [Command Line API] }"); |
| 683 createBoundFunctionProperty( | 608 createBoundFunctionProperty( |
| 684 context, commandLineAPI, data, "debug", | 609 context, commandLineAPI, data, "debug", |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 ->GetOwnPropertyDescriptor( | 743 ->GetOwnPropertyDescriptor( |
| 819 m_context, v8::Local<v8::String>::Cast(name)) | 744 m_context, v8::Local<v8::String>::Cast(name)) |
| 820 .ToLocal(&descriptor); | 745 .ToLocal(&descriptor); |
| 821 DCHECK(success); | 746 DCHECK(success); |
| 822 USE(success); | 747 USE(success); |
| 823 } | 748 } |
| 824 } | 749 } |
| 825 } | 750 } |
| 826 | 751 |
| 827 } // namespace v8_inspector | 752 } // namespace v8_inspector |
| OLD | NEW |