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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD
etails) | 464 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD
etails) |
465 { | 465 { |
466 v8::DebugEvent event = eventDetails.GetEvent(); | 466 v8::DebugEvent event = eventDetails.GetEvent(); |
467 | 467 |
468 if (event == v8::BreakForCommand) { | 468 if (event == v8::BreakForCommand) { |
469 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie
ntData()); | 469 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie
ntData()); |
470 data->task()->run(); | 470 data->task()->run(); |
471 return; | 471 return; |
472 } | 472 } |
473 | 473 |
474 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except
ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C
ompileError) | 474 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except
ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C
ompileError && event != v8::PromiseEvent) |
475 return; | 475 return; |
476 | 476 |
477 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); | 477 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); |
478 ASSERT(!eventContext.IsEmpty()); | 478 ASSERT(!eventContext.IsEmpty()); |
479 | 479 |
480 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); | 480 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); |
481 if (listener) { | 481 if (listener) { |
482 v8::HandleScope scope(m_isolate); | 482 v8::HandleScope scope(m_isolate); |
483 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol
ate); | 483 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol
ate); |
484 if (event == v8::BeforeCompile) { | 484 if (event == v8::BeforeCompile) { |
(...skipping 11 matching lines...) Expand all Loading... |
496 v8::Handle<v8::Value> exception = callInternalGetterFunction(eventDa
ta, "exception", m_isolate); | 496 v8::Handle<v8::Value> exception = callInternalGetterFunction(eventDa
ta, "exception", m_isolate); |
497 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get
ExecutionState(), exception, v8::Handle<v8::Array>()); | 497 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get
ExecutionState(), exception, v8::Handle<v8::Array>()); |
498 } else if (event == v8::Break) { | 498 } else if (event == v8::Break) { |
499 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8
::Function>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getBreakpointNu
mbers"))); | 499 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8
::Function>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getBreakpointNu
mbers"))); |
500 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; | 500 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; |
501 v8::Handle<v8::Value> hitBreakpoints = V8ScriptRunner::callInternalF
unction(getBreakpointNumbersFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), ar
gv, m_isolate); | 501 v8::Handle<v8::Value> hitBreakpoints = V8ScriptRunner::callInternalF
unction(getBreakpointNumbersFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), ar
gv, m_isolate); |
502 ASSERT(hitBreakpoints->IsArray()); | 502 ASSERT(hitBreakpoints->IsArray()); |
503 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get
ExecutionState(), v8::Handle<v8::Value>(), hitBreakpoints.As<v8::Array>()); | 503 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get
ExecutionState(), v8::Handle<v8::Value>(), hitBreakpoints.As<v8::Array>()); |
504 } else if (event == v8::AsyncTaskEvent) { | 504 } else if (event == v8::AsyncTaskEvent) { |
505 handleV8AsyncTaskEvent(listener, ScriptState::from(eventContext), ev
entDetails.GetExecutionState(), eventDetails.GetEventData()); | 505 handleV8AsyncTaskEvent(listener, ScriptState::from(eventContext), ev
entDetails.GetExecutionState(), eventDetails.GetEventData()); |
| 506 } else if (event == v8::PromiseEvent) { |
| 507 handleV8PromiseEvent(listener, ScriptState::from(eventContext), even
tDetails.GetExecutionState(), eventDetails.GetEventData()); |
506 } | 508 } |
507 } | 509 } |
508 } | 510 } |
509 | 511 |
510 void ScriptDebugServer::handleV8AsyncTaskEvent(ScriptDebugListener* listener, Sc
riptState* pausedScriptState, v8::Handle<v8::Object> executionState, v8::Handle<
v8::Object> eventData) | 512 void ScriptDebugServer::handleV8AsyncTaskEvent(ScriptDebugListener* listener, Sc
riptState* pausedScriptState, v8::Handle<v8::Object> executionState, v8::Handle<
v8::Object> eventData) |
511 { | 513 { |
512 String type = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio
n(eventData, "type", m_isolate)); | 514 String type = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio
n(eventData, "type", m_isolate)); |
513 String name = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio
n(eventData, "name", m_isolate)); | 515 String name = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio
n(eventData, "name", m_isolate)); |
514 int id = callInternalGetterFunction(eventData, "id", m_isolate)->ToInteger()
->Value(); | 516 int id = callInternalGetterFunction(eventData, "id", m_isolate)->ToInteger()
->Value(); |
515 | 517 |
516 // FIXME: Remove when not needed. | 518 // FIXME: Remove when not needed. |
517 if (name == "Promise.Resolved") | 519 if (name == "Promise.Resolved") |
518 name = "Promise.resolve"; | 520 name = "Promise.resolve"; |
519 else if (name == "Promise.Rejected") | 521 else if (name == "Promise.Rejected") |
520 name = "Promise.reject"; | 522 name = "Promise.reject"; |
521 | 523 |
522 m_pausedScriptState = pausedScriptState; | 524 m_pausedScriptState = pausedScriptState; |
523 m_executionState = executionState; | 525 m_executionState = executionState; |
524 listener->didReceiveV8AsyncTaskEvent(pausedScriptState->executionContext(),
type, name, id); | 526 listener->didReceiveV8AsyncTaskEvent(pausedScriptState->executionContext(),
type, name, id); |
525 m_pausedScriptState.clear(); | 527 m_pausedScriptState.clear(); |
526 m_executionState.Clear(); | 528 m_executionState.Clear(); |
527 } | 529 } |
528 | 530 |
| 531 void ScriptDebugServer::handleV8PromiseEvent(ScriptDebugListener* listener, Scri
ptState* pausedScriptState, v8::Handle<v8::Object> executionState, v8::Handle<v8
::Object> eventData) |
| 532 { |
| 533 v8::Handle<v8::Value> argv[] = { eventData }; |
| 534 v8::Local<v8::Object> promiseDetails = callDebuggerMethod("getPromiseDetails
", 1, argv)->ToObject(); |
| 535 v8::Handle<v8::Object> promise = promiseDetails->Get(v8AtomicString(m_isolat
e, "promise"))->ToObject(); |
| 536 int status = promiseDetails->Get(v8AtomicString(m_isolate, "status"))->ToInt
eger()->Value(); |
| 537 v8::Handle<v8::Value> parentPromise = promiseDetails->Get(v8AtomicString(m_i
solate, "parentPromise")); |
| 538 |
| 539 m_pausedScriptState = pausedScriptState; |
| 540 m_executionState = executionState; |
| 541 listener->didReceiveV8PromiseEvent(pausedScriptState, promise, parentPromise
, status); |
| 542 m_pausedScriptState.clear(); |
| 543 m_executionState.Clear(); |
| 544 } |
| 545 |
529 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8
::Handle<v8::Object> object, CompileResult compileResult) | 546 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8
::Handle<v8::Object> object, CompileResult compileResult) |
530 { | 547 { |
531 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id")); | 548 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id")); |
532 ASSERT(!id.IsEmpty() && id->IsInt32()); | 549 ASSERT(!id.IsEmpty() && id->IsInt32()); |
533 String sourceID = String::number(id->Int32Value()); | 550 String sourceID = String::number(id->Int32Value()); |
534 | 551 |
535 ScriptDebugListener::Script script; | 552 ScriptDebugListener::Script script; |
536 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString
(m_isolate, "name"))); | 553 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString
(m_isolate, "name"))); |
537 script.sourceURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v8Atomic
String(m_isolate, "sourceURL"))); | 554 script.sourceURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v8Atomic
String(m_isolate, "sourceURL"))); |
538 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v
8AtomicString(m_isolate, "sourceMappingURL"))); | 555 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v
8AtomicString(m_isolate, "sourceMappingURL"))); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 { | 689 { |
673 return PassOwnPtr<ScriptSourceCode>(); | 690 return PassOwnPtr<ScriptSourceCode>(); |
674 } | 691 } |
675 | 692 |
676 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou
rce, const String& url, const String& functionName) | 693 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou
rce, const String& url, const String& functionName) |
677 { | 694 { |
678 return source; | 695 return source; |
679 } | 696 } |
680 | 697 |
681 } // namespace blink | 698 } // namespace blink |
OLD | NEW |