Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: Source/bindings/v8/ScriptDebugServer.cpp

Issue 272613002: DevTools: implemented scriptFailedToParse protocol event (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD etails) 444 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD etails)
445 { 445 {
446 v8::DebugEvent event = eventDetails.GetEvent(); 446 v8::DebugEvent event = eventDetails.GetEvent();
447 447
448 if (event == v8::BreakForCommand) { 448 if (event == v8::BreakForCommand) {
449 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie ntData()); 449 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie ntData());
450 data->task()->run(); 450 data->task()->run();
451 return; 451 return;
452 } 452 }
453 453
454 if (event != v8::Break && event != v8::Exception && event != v8::AfterCompil e && event != v8::BeforeCompile) 454 if (event != v8::Break && event != v8::Exception && event != v8::AfterCompil e && event != v8::BeforeCompile && event != v8::ScriptFailedToParse)
455 return; 455 return;
456 456
457 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); 457 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext();
458 ASSERT(!eventContext.IsEmpty()); 458 ASSERT(!eventContext.IsEmpty());
459 459
460 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); 460 ScriptDebugListener* listener = getDebugListenerForContext(eventContext);
461 if (listener) { 461 if (listener) {
462 v8::HandleScope scope(m_isolate); 462 v8::HandleScope scope(m_isolate);
463 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol ate); 463 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol ate);
464 if (event == v8::BeforeCompile) { 464 if (event == v8::BeforeCompile) {
(...skipping 26 matching lines...) Expand all
491 ASSERT(hitBreakpoints->IsArray()); 491 ASSERT(hitBreakpoints->IsArray());
492 RefPtr<JavaScriptCallFrame> topFrame = wrapCallFrames(eventDetails.G etExecutionState(), 1, NoScopes); 492 RefPtr<JavaScriptCallFrame> topFrame = wrapCallFrames(eventDetails.G etExecutionState(), 1, NoScopes);
493 ScriptDebugListener::SkipPauseRequest skipRequest; 493 ScriptDebugListener::SkipPauseRequest skipRequest;
494 if (v8::Handle<v8::Array>::Cast(hitBreakpoints)->Length()) 494 if (v8::Handle<v8::Array>::Cast(hitBreakpoints)->Length())
495 skipRequest = listener->shouldSkipBreakpointPause(topFrame); 495 skipRequest = listener->shouldSkipBreakpointPause(topFrame);
496 else 496 else
497 skipRequest = listener->shouldSkipStepPause(topFrame); 497 skipRequest = listener->shouldSkipStepPause(topFrame);
498 if (executeSkipPauseRequest(skipRequest, eventDetails.GetExecutionSt ate())) 498 if (executeSkipPauseRequest(skipRequest, eventDetails.GetExecutionSt ate()))
499 return; 499 return;
500 handleProgramBreak(eventDetails, v8::Handle<v8::Value>(), hitBreakpo ints.As<v8::Array>()); 500 handleProgramBreak(eventDetails, v8::Handle<v8::Value>(), hitBreakpo ints.As<v8::Array>());
501 } else if (event == v8::ScriptFailedToParse) {
vsevik 2014/06/27 12:35:14 Also the code is very similar with AfterCompile ha
vsevik 2014/06/27 12:35:14 Please rebaseline this (I think the event name cha
502 v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
503 v8::Handle<v8::Function> getAfterCompileScript = v8::Local<v8::Funct ion>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getAfterCompileScript" )));
504 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() };
505 v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(g etAfterCompileScript, debuggerScript, WTF_ARRAY_LENGTH(argv), argv, m_isolate);
506 ASSERT(value->IsObject());
507 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
508 dispatchFailedToParseSource(listener, object);
501 } 509 }
502 } 510 }
503 } 511 }
504 512
505 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8 ::Handle<v8::Object> object) 513 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8 ::Handle<v8::Object> object)
506 { 514 {
507 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id")); 515 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id"));
508 ASSERT(!id.IsEmpty() && id->IsInt32()); 516 ASSERT(!id.IsEmpty() && id->IsInt32());
509 String sourceID = String::number(id->Int32Value()); 517 String sourceID = String::number(id->Int32Value());
510 518
511 ScriptDebugListener::Script script; 519 ScriptDebugListener::Script script;
512 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString (m_isolate, "name"))); 520 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString (m_isolate, "name")));
513 script.source = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicStr ing(m_isolate, "source"))); 521 script.source = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicStr ing(m_isolate, "source")));
514 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v 8AtomicString(m_isolate, "sourceMappingURL"))); 522 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v 8AtomicString(m_isolate, "sourceMappingURL")));
515 script.startLine = object->Get(v8AtomicString(m_isolate, "startLine"))->ToIn teger()->Value(); 523 script.startLine = object->Get(v8AtomicString(m_isolate, "startLine"))->ToIn teger()->Value();
516 script.startColumn = object->Get(v8AtomicString(m_isolate, "startColumn"))-> ToInteger()->Value(); 524 script.startColumn = object->Get(v8AtomicString(m_isolate, "startColumn"))-> ToInteger()->Value();
517 script.endLine = object->Get(v8AtomicString(m_isolate, "endLine"))->ToIntege r()->Value(); 525 script.endLine = object->Get(v8AtomicString(m_isolate, "endLine"))->ToIntege r()->Value();
518 script.endColumn = object->Get(v8AtomicString(m_isolate, "endColumn"))->ToIn teger()->Value(); 526 script.endColumn = object->Get(v8AtomicString(m_isolate, "endColumn"))->ToIn teger()->Value();
519 script.isContentScript = object->Get(v8AtomicString(m_isolate, "isContentScr ipt"))->ToBoolean()->Value(); 527 script.isContentScript = object->Get(v8AtomicString(m_isolate, "isContentScr ipt"))->ToBoolean()->Value();
520 528
521 listener->didParseSource(sourceID, script); 529 listener->didParseSource(sourceID, script);
522 } 530 }
523 531
532 void ScriptDebugServer::dispatchFailedToParseSource(ScriptDebugListener* listene r, v8::Handle<v8::Object> object)
vsevik 2014/06/27 12:35:14 This one should be merged with the method above.
533 {
534 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id"));
535 ASSERT(!id.IsEmpty() && id->IsInt32());
536 String sourceID = String::number(id->Int32Value());
537
538 ScriptDebugListener::Script script;
539 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString (m_isolate, "name")));
540 script.source = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicStr ing(m_isolate, "source")));
541 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v 8AtomicString(m_isolate, "sourceMappingURL")));
542 script.startLine = object->Get(v8AtomicString(m_isolate, "startLine"))->ToIn teger()->Value();
543 script.startColumn = object->Get(v8AtomicString(m_isolate, "startColumn"))-> ToInteger()->Value();
544 script.endLine = object->Get(v8AtomicString(m_isolate, "endLine"))->ToIntege r()->Value();
545 script.endColumn = object->Get(v8AtomicString(m_isolate, "endColumn"))->ToIn teger()->Value();
546 script.isContentScript = object->Get(v8AtomicString(m_isolate, "isContentScr ipt"))->ToBoolean()->Value();
547
548 listener->failedToParseSource(sourceID, script);
549 }
550
524 void ScriptDebugServer::ensureDebuggerScriptCompiled() 551 void ScriptDebugServer::ensureDebuggerScriptCompiled()
525 { 552 {
526 if (!m_debuggerScript.isEmpty()) 553 if (!m_debuggerScript.isEmpty())
527 return; 554 return;
528 555
529 v8::HandleScope scope(m_isolate); 556 v8::HandleScope scope(m_isolate);
530 v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); 557 v8::Context::Scope contextScope(v8::Debug::GetDebugContext());
531 v8::Handle<v8::String> source = v8String(m_isolate, String(reinterpret_cast< const char*>(DebuggerScriptSource_js), sizeof(DebuggerScriptSource_js))); 558 v8::Handle<v8::String> source = v8String(m_isolate, String(reinterpret_cast< const char*>(DebuggerScriptSource_js), sizeof(DebuggerScriptSource_js)));
532 v8::Local<v8::Value> value = V8ScriptRunner::compileAndRunInternalScript(sou rce, m_isolate); 559 v8::Local<v8::Value> value = V8ScriptRunner::compileAndRunInternalScript(sou rce, m_isolate);
533 ASSERT(!value.IsEmpty()); 560 ASSERT(!value.IsEmpty());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 { 659 {
633 return PassOwnPtr<ScriptSourceCode>(); 660 return PassOwnPtr<ScriptSourceCode>();
634 } 661 }
635 662
636 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou rce, const String& url, const String& functionName) 663 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou rce, const String& url, const String& functionName)
637 { 664 {
638 return source; 665 return source;
639 } 666 }
640 667
641 } // namespace WebCore 668 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698