OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD
etails) | 475 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD
etails) |
476 { | 476 { |
477 v8::DebugEvent event = eventDetails.GetEvent(); | 477 v8::DebugEvent event = eventDetails.GetEvent(); |
478 | 478 |
479 if (event == v8::BreakForCommand) { | 479 if (event == v8::BreakForCommand) { |
480 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie
ntData()); | 480 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie
ntData()); |
481 data->task()->run(); | 481 data->task()->run(); |
482 return; | 482 return; |
483 } | 483 } |
484 | 484 |
485 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except
ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C
ompileError) | 485 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except
ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C
ompileError && event != v8::PromiseEvent) |
486 return; | 486 return; |
487 | 487 |
488 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); | 488 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); |
489 ASSERT(!eventContext.IsEmpty()); | 489 ASSERT(!eventContext.IsEmpty()); |
490 | 490 |
491 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); | 491 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); |
492 if (listener) { | 492 if (listener) { |
493 v8::HandleScope scope(m_isolate); | 493 v8::HandleScope scope(m_isolate); |
494 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol
ate); | 494 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol
ate); |
495 if (event == v8::BeforeCompile) { | 495 if (event == v8::BeforeCompile) { |
(...skipping 11 matching lines...) Expand all Loading... |
507 v8::Handle<v8::Value> exception = callInternalGetterFunction(eventDa
ta, "exception", m_isolate); | 507 v8::Handle<v8::Value> exception = callInternalGetterFunction(eventDa
ta, "exception", m_isolate); |
508 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get
ExecutionState(), exception, v8::Handle<v8::Array>()); | 508 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get
ExecutionState(), exception, v8::Handle<v8::Array>()); |
509 } else if (event == v8::Break) { | 509 } else if (event == v8::Break) { |
510 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8
::Function>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getBreakpointNu
mbers"))); | 510 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8
::Function>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getBreakpointNu
mbers"))); |
511 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; | 511 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; |
512 v8::Handle<v8::Value> hitBreakpoints = V8ScriptRunner::callInternalF
unction(getBreakpointNumbersFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), ar
gv, m_isolate); | 512 v8::Handle<v8::Value> hitBreakpoints = V8ScriptRunner::callInternalF
unction(getBreakpointNumbersFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), ar
gv, m_isolate); |
513 ASSERT(hitBreakpoints->IsArray()); | 513 ASSERT(hitBreakpoints->IsArray()); |
514 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get
ExecutionState(), v8::Handle<v8::Value>(), hitBreakpoints.As<v8::Array>()); | 514 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get
ExecutionState(), v8::Handle<v8::Value>(), hitBreakpoints.As<v8::Array>()); |
515 } else if (event == v8::AsyncTaskEvent) { | 515 } else if (event == v8::AsyncTaskEvent) { |
516 handleV8AsyncTaskEvent(listener, ScriptState::from(eventContext), ev
entDetails.GetExecutionState(), eventDetails.GetEventData()); | 516 handleV8AsyncTaskEvent(listener, ScriptState::from(eventContext), ev
entDetails.GetExecutionState(), eventDetails.GetEventData()); |
| 517 } else if (event == v8::PromiseEvent) { |
| 518 handleV8PromiseEvent(listener, ScriptState::from(eventContext), even
tDetails.GetExecutionState(), eventDetails.GetEventData()); |
517 } | 519 } |
518 } | 520 } |
519 } | 521 } |
520 | 522 |
521 void ScriptDebugServer::handleV8AsyncTaskEvent(ScriptDebugListener* listener, Sc
riptState* pausedScriptState, v8::Handle<v8::Object> executionState, v8::Handle<
v8::Object> eventData) | 523 void ScriptDebugServer::handleV8AsyncTaskEvent(ScriptDebugListener* listener, Sc
riptState* pausedScriptState, v8::Handle<v8::Object> executionState, v8::Handle<
v8::Object> eventData) |
522 { | 524 { |
523 String type = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio
n(eventData, "type", m_isolate)); | 525 String type = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio
n(eventData, "type", m_isolate)); |
524 String name = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio
n(eventData, "name", m_isolate)); | 526 String name = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio
n(eventData, "name", m_isolate)); |
525 int id = callInternalGetterFunction(eventData, "id", m_isolate)->ToInteger()
->Value(); | 527 int id = callInternalGetterFunction(eventData, "id", m_isolate)->ToInteger()
->Value(); |
526 | 528 |
527 m_pausedScriptState = pausedScriptState; | 529 m_pausedScriptState = pausedScriptState; |
528 m_executionState = executionState; | 530 m_executionState = executionState; |
529 listener->didReceiveV8AsyncTaskEvent(pausedScriptState->executionContext(),
type, name, id); | 531 listener->didReceiveV8AsyncTaskEvent(pausedScriptState->executionContext(),
type, name, id); |
530 m_pausedScriptState.clear(); | 532 m_pausedScriptState.clear(); |
531 m_executionState.Clear(); | 533 m_executionState.Clear(); |
532 } | 534 } |
533 | 535 |
| 536 void ScriptDebugServer::handleV8PromiseEvent(ScriptDebugListener* listener, Scri
ptState* pausedScriptState, v8::Handle<v8::Object> executionState, v8::Handle<v8
::Object> eventData) |
| 537 { |
| 538 v8::Handle<v8::Value> argv[] = { eventData }; |
| 539 v8::Local<v8::Object> promiseDetails = callDebuggerMethod("getPromiseDetails
", 1, argv)->ToObject(); |
| 540 v8::Handle<v8::Object> promise = promiseDetails->Get(v8AtomicString(m_isolat
e, "promise"))->ToObject(); |
| 541 int status = promiseDetails->Get(v8AtomicString(m_isolate, "status"))->ToInt
eger()->Value(); |
| 542 v8::Handle<v8::Value> parentPromise = promiseDetails->Get(v8AtomicString(m_i
solate, "parentPromise")); |
| 543 |
| 544 m_pausedScriptState = pausedScriptState; |
| 545 m_executionState = executionState; |
| 546 listener->didReceiveV8PromiseEvent(pausedScriptState, promise, parentPromise
, status); |
| 547 m_pausedScriptState.clear(); |
| 548 m_executionState.Clear(); |
| 549 } |
| 550 |
534 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8
::Handle<v8::Object> object, CompileResult compileResult) | 551 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8
::Handle<v8::Object> object, CompileResult compileResult) |
535 { | 552 { |
536 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id")); | 553 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id")); |
537 ASSERT(!id.IsEmpty() && id->IsInt32()); | 554 ASSERT(!id.IsEmpty() && id->IsInt32()); |
538 String sourceID = String::number(id->Int32Value()); | 555 String sourceID = String::number(id->Int32Value()); |
539 | 556 |
540 ScriptDebugListener::Script script; | 557 ScriptDebugListener::Script script; |
541 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString
(m_isolate, "name"))); | 558 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString
(m_isolate, "name"))); |
542 script.sourceURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v8Atomic
String(m_isolate, "sourceURL"))); | 559 script.sourceURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v8Atomic
String(m_isolate, "sourceURL"))); |
543 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v
8AtomicString(m_isolate, "sourceMappingURL"))); | 560 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v
8AtomicString(m_isolate, "sourceMappingURL"))); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 { | 694 { |
678 return PassOwnPtr<ScriptSourceCode>(); | 695 return PassOwnPtr<ScriptSourceCode>(); |
679 } | 696 } |
680 | 697 |
681 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou
rce, const String& url, const String& functionName) | 698 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou
rce, const String& url, const String& functionName) |
682 { | 699 { |
683 return source; | 700 return source; |
684 } | 701 } |
685 | 702 |
686 } // namespace blink | 703 } // namespace blink |
OLD | NEW |