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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 m_debuggerContext.Reset(); | 100 m_debuggerContext.Reset(); |
101 m_callFrameWrapperTemplate.Reset(); | 101 m_callFrameWrapperTemplate.Reset(); |
102 v8::Debug::SetDebugEventListener(m_isolate, nullptr); | 102 v8::Debug::SetDebugEventListener(m_isolate, nullptr); |
103 } | 103 } |
104 | 104 |
105 bool V8DebuggerImpl::enabled() const | 105 bool V8DebuggerImpl::enabled() const |
106 { | 106 { |
107 return !m_debuggerScript.IsEmpty(); | 107 return !m_debuggerScript.IsEmpty(); |
108 } | 108 } |
109 | 109 |
110 void V8Debugger::setContextDebugData(v8::Local<v8::Context> context, const Strin
g& type, int contextGroupId) | 110 void V8Debugger::setContextDebugData(v8::Local<v8::Context> context, const Strin
g16& type, int contextGroupId) |
111 { | 111 { |
112 int contextId = atomicIncrement(&s_lastContextId); | 112 int contextId = atomicIncrement(&s_lastContextId); |
113 String debugData = String::number(contextGroupId) + "," + String::number(con
textId) + "," + type; | 113 String16 debugData = String16::number(contextGroupId) + "," + String16::numb
er(contextId) + "," + type; |
114 v8::HandleScope scope(context->GetIsolate()); | 114 v8::HandleScope scope(context->GetIsolate()); |
115 v8::Context::Scope contextScope(context); | 115 v8::Context::Scope contextScope(context); |
116 context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8S
tring(context->GetIsolate(), debugData)); | 116 context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8S
tring(context->GetIsolate(), debugData)); |
117 } | 117 } |
118 | 118 |
119 int V8Debugger::contextId(v8::Local<v8::Context> context) | 119 int V8Debugger::contextId(v8::Local<v8::Context> context) |
120 { | 120 { |
121 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co
ntext::kDebugIdIndex)); | 121 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co
ntext::kDebugIdIndex)); |
122 if (data.IsEmpty() || !data->IsString()) | 122 if (data.IsEmpty() || !data->IsString()) |
123 return 0; | 123 return 0; |
124 String dataString = toWTFString(data.As<v8::String>()); | 124 String16 dataString = toProtocolString(data.As<v8::String>()); |
125 if (dataString.isEmpty()) | 125 if (dataString.isEmpty()) |
126 return 0; | 126 return 0; |
127 size_t commaPos = dataString.find(","); | 127 size_t commaPos = dataString.find(","); |
128 if (commaPos == kNotFound) | 128 if (commaPos == kNotFound) |
129 return 0; | 129 return 0; |
130 size_t commaPos2 = dataString.find(",", commaPos + 1); | 130 size_t commaPos2 = dataString.find(",", commaPos + 1); |
131 if (commaPos2 == kNotFound) | 131 if (commaPos2 == kNotFound) |
132 return 0; | 132 return 0; |
133 return dataString.substring(commaPos + 1, commaPos2 - commaPos - 1).toInt(); | 133 return dataString.substring(commaPos + 1, commaPos2 - commaPos - 1).toInt(); |
134 } | 134 } |
135 | 135 |
136 static int getGroupId(v8::Local<v8::Context> context) | 136 static int getGroupId(v8::Local<v8::Context> context) |
137 { | 137 { |
138 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co
ntext::kDebugIdIndex)); | 138 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co
ntext::kDebugIdIndex)); |
139 if (data.IsEmpty() || !data->IsString()) | 139 if (data.IsEmpty() || !data->IsString()) |
140 return 0; | 140 return 0; |
141 String dataString = toWTFString(data.As<v8::String>()); | 141 String16 dataString = toProtocolString(data.As<v8::String>()); |
142 if (dataString.isEmpty()) | 142 if (dataString.isEmpty()) |
143 return 0; | 143 return 0; |
144 size_t commaPos = dataString.find(","); | 144 size_t commaPos = dataString.find(","); |
145 if (commaPos == kNotFound) | 145 if (commaPos == kNotFound) |
146 return 0; | 146 return 0; |
147 return dataString.left(commaPos).toInt(); | 147 return dataString.left(commaPos).toInt(); |
148 } | 148 } |
149 | 149 |
150 void V8DebuggerImpl::addAgent(int contextGroupId, V8DebuggerAgentImpl* agent) | 150 void V8DebuggerImpl::addAgent(int contextGroupId, V8DebuggerAgentImpl* agent) |
151 { | 151 { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 v8::Local<v8::Value> value; | 196 v8::Local<v8::Value> value; |
197 if (!m_client->callInternalFunction(getScriptsFunction, debuggerScript, WTF_
ARRAY_LENGTH(argv), argv).ToLocal(&value)) | 197 if (!m_client->callInternalFunction(getScriptsFunction, debuggerScript, WTF_
ARRAY_LENGTH(argv), argv).ToLocal(&value)) |
198 return; | 198 return; |
199 ASSERT(value->IsArray()); | 199 ASSERT(value->IsArray()); |
200 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); | 200 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); |
201 result.resize(scriptsArray->Length()); | 201 result.resize(scriptsArray->Length()); |
202 for (unsigned i = 0; i < scriptsArray->Length(); ++i) | 202 for (unsigned i = 0; i < scriptsArray->Length(); ++i) |
203 result[i] = createParsedScript(v8::Local<v8::Object>::Cast(scriptsArray-
>Get(v8::Integer::New(m_isolate, i))), true); | 203 result[i] = createParsedScript(v8::Local<v8::Object>::Cast(scriptsArray-
>Get(v8::Integer::New(m_isolate, i))), true); |
204 } | 204 } |
205 | 205 |
206 String V8DebuggerImpl::setBreakpoint(const String& sourceID, const ScriptBreakpo
int& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool inte
rstatementLocation) | 206 String16 V8DebuggerImpl::setBreakpoint(const String16& sourceID, const ScriptBre
akpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool
interstatementLocation) |
207 { | 207 { |
208 v8::HandleScope scope(m_isolate); | 208 v8::HandleScope scope(m_isolate); |
209 v8::Context::Scope contextScope(debuggerContext()); | 209 v8::Context::Scope contextScope(debuggerContext()); |
210 | 210 |
211 v8::Local<v8::Object> info = v8::Object::New(m_isolate); | 211 v8::Local<v8::Object> info = v8::Object::New(m_isolate); |
212 info->Set(v8InternalizedString("sourceID"), toV8String(m_isolate, sourceID))
; | 212 info->Set(v8InternalizedString("sourceID"), toV8String(m_isolate, sourceID))
; |
213 info->Set(v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, sc
riptBreakpoint.lineNumber)); | 213 info->Set(v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, sc
riptBreakpoint.lineNumber)); |
214 info->Set(v8InternalizedString("columnNumber"), v8::Integer::New(m_isolate,
scriptBreakpoint.columnNumber)); | 214 info->Set(v8InternalizedString("columnNumber"), v8::Integer::New(m_isolate,
scriptBreakpoint.columnNumber)); |
215 info->Set(v8InternalizedString("interstatementLocation"), v8Boolean(intersta
tementLocation, m_isolate)); | 215 info->Set(v8InternalizedString("interstatementLocation"), v8Boolean(intersta
tementLocation, m_isolate)); |
216 info->Set(v8InternalizedString("condition"), toV8String(m_isolate, scriptBre
akpoint.condition)); | 216 info->Set(v8InternalizedString("condition"), toV8String(m_isolate, scriptBre
akpoint.condition)); |
217 | 217 |
218 v8::Local<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cas
t(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("setBreakpoint"))); | 218 v8::Local<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cas
t(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("setBreakpoint"))); |
219 v8::Local<v8::Value> breakpointId = v8::Debug::Call(debuggerContext(), setBr
eakpointFunction, info).ToLocalChecked(); | 219 v8::Local<v8::Value> breakpointId = v8::Debug::Call(debuggerContext(), setBr
eakpointFunction, info).ToLocalChecked(); |
220 if (!breakpointId->IsString()) | 220 if (!breakpointId->IsString()) |
221 return ""; | 221 return ""; |
222 *actualLineNumber = info->Get(v8InternalizedString("lineNumber"))->Int32Valu
e(); | 222 *actualLineNumber = info->Get(v8InternalizedString("lineNumber"))->Int32Valu
e(); |
223 *actualColumnNumber = info->Get(v8InternalizedString("columnNumber"))->Int32
Value(); | 223 *actualColumnNumber = info->Get(v8InternalizedString("columnNumber"))->Int32
Value(); |
224 return toWTFString(breakpointId.As<v8::String>()); | 224 return toProtocolString(breakpointId.As<v8::String>()); |
225 } | 225 } |
226 | 226 |
227 void V8DebuggerImpl::removeBreakpoint(const String& breakpointId) | 227 void V8DebuggerImpl::removeBreakpoint(const String16& breakpointId) |
228 { | 228 { |
229 v8::HandleScope scope(m_isolate); | 229 v8::HandleScope scope(m_isolate); |
230 v8::Context::Scope contextScope(debuggerContext()); | 230 v8::Context::Scope contextScope(debuggerContext()); |
231 | 231 |
232 v8::Local<v8::Object> info = v8::Object::New(m_isolate); | 232 v8::Local<v8::Object> info = v8::Object::New(m_isolate); |
233 info->Set(v8InternalizedString("breakpointId"), toV8String(m_isolate, breakp
ointId)); | 233 info->Set(v8InternalizedString("breakpointId"), toV8String(m_isolate, breakp
ointId)); |
234 | 234 |
235 v8::Local<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>::
Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("removeBreakpoint
"))); | 235 v8::Local<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>::
Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("removeBreakpoint
"))); |
236 v8::Debug::Call(debuggerContext(), removeBreakpointFunction, info).ToLocalCh
ecked(); | 236 v8::Debug::Call(debuggerContext(), removeBreakpointFunction, info).ToLocalCh
ecked(); |
237 } | 237 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 void V8DebuggerImpl::clearStepping() | 369 void V8DebuggerImpl::clearStepping() |
370 { | 370 { |
371 ASSERT(enabled()); | 371 ASSERT(enabled()); |
372 v8::HandleScope scope(m_isolate); | 372 v8::HandleScope scope(m_isolate); |
373 v8::Context::Scope contextScope(debuggerContext()); | 373 v8::Context::Scope contextScope(debuggerContext()); |
374 | 374 |
375 v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) }; | 375 v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) }; |
376 callDebuggerMethod("clearStepping", 0, argv); | 376 callDebuggerMethod("clearStepping", 0, argv); |
377 } | 377 } |
378 | 378 |
379 bool V8DebuggerImpl::setScriptSource(const String& sourceID, const String& newCo
ntent, bool preview, String* error, Maybe<protocol::Debugger::SetScriptSourceErr
or>* errorData, v8::Global<v8::Object>* newCallFrames, Maybe<bool>* stackChanged
) | 379 bool V8DebuggerImpl::setScriptSource(const String16& sourceID, const String16& n
ewContent, bool preview, ErrorString* error, Maybe<protocol::Debugger::SetScript
SourceError>* errorData, v8::Global<v8::Object>* newCallFrames, Maybe<bool>* sta
ckChanged) |
380 { | 380 { |
381 class EnableLiveEditScope { | 381 class EnableLiveEditScope { |
382 public: | 382 public: |
383 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) | 383 explicit EnableLiveEditScope(v8::Isolate* isolate) : m_isolate(isolate) |
384 { | 384 { |
385 v8::Debug::SetLiveEditEnabled(m_isolate, true); | 385 v8::Debug::SetLiveEditEnabled(m_isolate, true); |
386 inLiveEditScope = true; | 386 inLiveEditScope = true; |
387 } | 387 } |
388 ~EnableLiveEditScope() | 388 ~EnableLiveEditScope() |
389 { | 389 { |
(...skipping 15 matching lines...) Expand all Loading... |
405 | 405 |
406 v8::Local<v8::Value> v8result; | 406 v8::Local<v8::Value> v8result; |
407 { | 407 { |
408 EnableLiveEditScope enableLiveEditScope(m_isolate); | 408 EnableLiveEditScope enableLiveEditScope(m_isolate); |
409 v8::TryCatch tryCatch(m_isolate); | 409 v8::TryCatch tryCatch(m_isolate); |
410 tryCatch.SetVerbose(false); | 410 tryCatch.SetVerbose(false); |
411 v8::MaybeLocal<v8::Value> maybeResult = callDebuggerMethod("liveEditScri
ptSource", 3, argv); | 411 v8::MaybeLocal<v8::Value> maybeResult = callDebuggerMethod("liveEditScri
ptSource", 3, argv); |
412 if (tryCatch.HasCaught()) { | 412 if (tryCatch.HasCaught()) { |
413 v8::Local<v8::Message> message = tryCatch.Message(); | 413 v8::Local<v8::Message> message = tryCatch.Message(); |
414 if (!message.IsEmpty()) | 414 if (!message.IsEmpty()) |
415 *error = toWTFStringWithTypeCheck(message->Get()); | 415 *error = toProtocolStringWithTypeCheck(message->Get()); |
416 else | 416 else |
417 *error = "Unknown error."; | 417 *error = "Unknown error."; |
418 return false; | 418 return false; |
419 } | 419 } |
420 v8result = maybeResult.ToLocalChecked(); | 420 v8result = maybeResult.ToLocalChecked(); |
421 } | 421 } |
422 ASSERT(!v8result.IsEmpty()); | 422 ASSERT(!v8result.IsEmpty()); |
423 v8::Local<v8::Object> resultTuple = v8result->ToObject(m_isolate); | 423 v8::Local<v8::Object> resultTuple = v8result->ToObject(m_isolate); |
424 int code = static_cast<int>(resultTuple->Get(0)->ToInteger(m_isolate)->Value
()); | 424 int code = static_cast<int>(resultTuple->Get(0)->ToInteger(m_isolate)->Value
()); |
425 switch (code) { | 425 switch (code) { |
426 case 0: | 426 case 0: |
427 { | 427 { |
428 *stackChanged = resultTuple->Get(1)->BooleanValue(); | 428 *stackChanged = resultTuple->Get(1)->BooleanValue(); |
429 // Call stack may have changed after if the edited function was on t
he stack. | 429 // Call stack may have changed after if the edited function was on t
he stack. |
430 if (!preview && isPaused()) | 430 if (!preview && isPaused()) |
431 newCallFrames->Reset(m_isolate, currentCallFrames()); | 431 newCallFrames->Reset(m_isolate, currentCallFrames()); |
432 return true; | 432 return true; |
433 } | 433 } |
434 // Compile error. | 434 // Compile error. |
435 case 1: | 435 case 1: |
436 { | 436 { |
437 *errorData = protocol::Debugger::SetScriptSourceError::create() | 437 *errorData = protocol::Debugger::SetScriptSourceError::create() |
438 .setMessage(toWTFStringWithTypeCheck(resultTuple->Get(2))) | 438 .setMessage(toProtocolStringWithTypeCheck(resultTuple->Get(2))) |
439 .setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Va
lue()) | 439 .setLineNumber(resultTuple->Get(3)->ToInteger(m_isolate)->Value(
)) |
440 .setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->
Value()).build(); | 440 .setColumnNumber(resultTuple->Get(4)->ToInteger(m_isolate)->Valu
e()).build(); |
441 return false; | 441 return false; |
442 } | 442 } |
443 } | 443 } |
444 *error = "Unknown error."; | 444 *error = "Unknown error."; |
445 return false; | 445 return false; |
446 } | 446 } |
447 | 447 |
448 int V8DebuggerImpl::frameCount() | 448 int V8DebuggerImpl::frameCount() |
449 { | 449 { |
450 ASSERT(isPaused()); | 450 ASSERT(isPaused()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 void V8DebuggerImpl::handleProgramBreak(v8::Local<v8::Context> pausedContext, v8
::Local<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8
::Array> hitBreakpointNumbers, bool isPromiseRejection) | 532 void V8DebuggerImpl::handleProgramBreak(v8::Local<v8::Context> pausedContext, v8
::Local<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8
::Array> hitBreakpointNumbers, bool isPromiseRejection) |
533 { | 533 { |
534 // Don't allow nested breaks. | 534 // Don't allow nested breaks. |
535 if (m_runningNestedMessageLoop) | 535 if (m_runningNestedMessageLoop) |
536 return; | 536 return; |
537 | 537 |
538 V8DebuggerAgentImpl* agent = getAgentForContext(pausedContext); | 538 V8DebuggerAgentImpl* agent = getAgentForContext(pausedContext); |
539 if (!agent) | 539 if (!agent) |
540 return; | 540 return; |
541 | 541 |
542 protocol::Vector<String> breakpointIds; | 542 protocol::Vector<String16> breakpointIds; |
543 if (!hitBreakpointNumbers.IsEmpty()) { | 543 if (!hitBreakpointNumbers.IsEmpty()) { |
544 breakpointIds.resize(hitBreakpointNumbers->Length()); | 544 breakpointIds.resize(hitBreakpointNumbers->Length()); |
545 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { | 545 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { |
546 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get
(i); | 546 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get
(i); |
547 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3
2()); | 547 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3
2()); |
548 breakpointIds[i] = String::number(hitBreakpointNumber->Int32Value())
; | 548 breakpointIds[i] = String16::number(hitBreakpointNumber->Int32Value(
)); |
549 } | 549 } |
550 } | 550 } |
551 | 551 |
552 m_pausedContext = pausedContext; | 552 m_pausedContext = pausedContext; |
553 m_executionState = executionState; | 553 m_executionState = executionState; |
554 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(pausedContext
, currentCallFrames(), exception, breakpointIds, isPromiseRejection); | 554 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(pausedContext
, currentCallFrames(), exception, breakpointIds, isPromiseRejection); |
555 if (result == V8DebuggerAgentImpl::RequestNoSkip) { | 555 if (result == V8DebuggerAgentImpl::RequestNoSkip) { |
556 m_runningNestedMessageLoop = true; | 556 m_runningNestedMessageLoop = true; |
557 int groupId = getGroupId(pausedContext); | 557 int groupId = getGroupId(pausedContext); |
558 ASSERT(groupId); | 558 ASSERT(groupId); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 handleV8AsyncTaskEvent(agent, eventContext, eventDetails.GetExec
utionState(), eventDetails.GetEventData()); | 628 handleV8AsyncTaskEvent(agent, eventContext, eventDetails.GetExec
utionState(), eventDetails.GetEventData()); |
629 } else if (event == v8::PromiseEvent) { | 629 } else if (event == v8::PromiseEvent) { |
630 if (agent->v8PromiseEventsEnabled()) | 630 if (agent->v8PromiseEventsEnabled()) |
631 handleV8PromiseEvent(agent, eventContext, eventDetails.GetExecut
ionState(), eventDetails.GetEventData()); | 631 handleV8PromiseEvent(agent, eventContext, eventDetails.GetExecut
ionState(), eventDetails.GetEventData()); |
632 } | 632 } |
633 } | 633 } |
634 } | 634 } |
635 | 635 |
636 void V8DebuggerImpl::handleV8AsyncTaskEvent(V8DebuggerAgentImpl* agent, v8::Loca
l<v8::Context> context, v8::Local<v8::Object> executionState, v8::Local<v8::Obje
ct> eventData) | 636 void V8DebuggerImpl::handleV8AsyncTaskEvent(V8DebuggerAgentImpl* agent, v8::Loca
l<v8::Context> context, v8::Local<v8::Object> executionState, v8::Local<v8::Obje
ct> eventData) |
637 { | 637 { |
638 String type = toWTFStringWithTypeCheck(callInternalGetterFunction(eventData,
"type")); | 638 String16 type = toProtocolStringWithTypeCheck(callInternalGetterFunction(eve
ntData, "type")); |
639 String name = toWTFStringWithTypeCheck(callInternalGetterFunction(eventData,
"name")); | 639 String16 name = toProtocolStringWithTypeCheck(callInternalGetterFunction(eve
ntData, "name")); |
640 int id = callInternalGetterFunction(eventData, "id")->ToInteger(m_isolate)->
Value(); | 640 int id = callInternalGetterFunction(eventData, "id")->ToInteger(m_isolate)->
Value(); |
641 | 641 |
642 m_pausedContext = context; | 642 m_pausedContext = context; |
643 m_executionState = executionState; | 643 m_executionState = executionState; |
644 agent->didReceiveV8AsyncTaskEvent(context, type, name, id); | 644 agent->didReceiveV8AsyncTaskEvent(context, type, name, id); |
645 m_pausedContext.Clear(); | 645 m_pausedContext.Clear(); |
646 m_executionState.Clear(); | 646 m_executionState.Clear(); |
647 } | 647 } |
648 | 648 |
649 void V8DebuggerImpl::handleV8PromiseEvent(V8DebuggerAgentImpl* agent, v8::Local<
v8::Context> context, v8::Local<v8::Object> executionState, v8::Local<v8::Object
> eventData) | 649 void V8DebuggerImpl::handleV8PromiseEvent(V8DebuggerAgentImpl* agent, v8::Local<
v8::Context> context, v8::Local<v8::Object> executionState, v8::Local<v8::Object
> eventData) |
(...skipping 12 matching lines...) Expand all Loading... |
662 m_pausedContext.Clear(); | 662 m_pausedContext.Clear(); |
663 m_executionState.Clear(); | 663 m_executionState.Clear(); |
664 } | 664 } |
665 | 665 |
666 V8DebuggerParsedScript V8DebuggerImpl::createParsedScript(v8::Local<v8::Object>
object, bool success) | 666 V8DebuggerParsedScript V8DebuggerImpl::createParsedScript(v8::Local<v8::Object>
object, bool success) |
667 { | 667 { |
668 v8::Local<v8::Value> id = object->Get(v8InternalizedString("id")); | 668 v8::Local<v8::Value> id = object->Get(v8InternalizedString("id")); |
669 ASSERT(!id.IsEmpty() && id->IsInt32()); | 669 ASSERT(!id.IsEmpty() && id->IsInt32()); |
670 | 670 |
671 V8DebuggerParsedScript parsedScript; | 671 V8DebuggerParsedScript parsedScript; |
672 parsedScript.scriptId = String::number(id->Int32Value()); | 672 parsedScript.scriptId = String16::number(id->Int32Value()); |
673 parsedScript.script.setURL(toWTFStringWithTypeCheck(object->Get(v8Internaliz
edString("name")))) | 673 parsedScript.script.setURL(toProtocolStringWithTypeCheck(object->Get(v8Inter
nalizedString("name")))) |
674 .setSourceURL(toWTFStringWithTypeCheck(object->Get(v8InternalizedString(
"sourceURL")))) | 674 .setSourceURL(toProtocolStringWithTypeCheck(object->Get(v8InternalizedSt
ring("sourceURL")))) |
675 .setSourceMappingURL(toWTFStringWithTypeCheck(object->Get(v8Internalized
String("sourceMappingURL")))) | 675 .setSourceMappingURL(toProtocolStringWithTypeCheck(object->Get(v8Interna
lizedString("sourceMappingURL")))) |
676 .setSource(toWTFStringWithTypeCheck(object->Get(v8InternalizedString("so
urce")))) | 676 .setSource(toProtocolStringWithTypeCheck(object->Get(v8InternalizedStrin
g("source")))) |
677 .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger(
m_isolate)->Value()) | 677 .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger(
m_isolate)->Value()) |
678 .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInte
ger(m_isolate)->Value()) | 678 .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInte
ger(m_isolate)->Value()) |
679 .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_is
olate)->Value()) | 679 .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_is
olate)->Value()) |
680 .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger(
m_isolate)->Value()) | 680 .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger(
m_isolate)->Value()) |
681 .setIsContentScript(object->Get(v8InternalizedString("isContentScript"))
->ToBoolean(m_isolate)->Value()) | 681 .setIsContentScript(object->Get(v8InternalizedString("isContentScript"))
->ToBoolean(m_isolate)->Value()) |
682 .setIsInternalScript(object->Get(v8InternalizedString("isInternalScript"
))->ToBoolean(m_isolate)->Value()) | 682 .setIsInternalScript(object->Get(v8InternalizedString("isInternalScript"
))->ToBoolean(m_isolate)->Value()) |
683 .setExecutionContextId(object->Get(v8InternalizedString("executionContex
tId"))->ToInteger(m_isolate)->Value()) | 683 .setExecutionContextId(object->Get(v8InternalizedString("executionContex
tId"))->ToInteger(m_isolate)->Value()) |
684 .setIsLiveEdit(inLiveEditScope); | 684 .setIsLiveEdit(inLiveEditScope); |
685 parsedScript.success = success; | 685 parsedScript.success = success; |
686 return parsedScript; | 686 return parsedScript; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 v8::Local<v8::Value> V8DebuggerImpl::collectionEntries(v8::Local<v8::Object>& ob
ject) | 738 v8::Local<v8::Value> V8DebuggerImpl::collectionEntries(v8::Local<v8::Object>& ob
ject) |
739 { | 739 { |
740 if (!enabled()) { | 740 if (!enabled()) { |
741 ASSERT_NOT_REACHED(); | 741 ASSERT_NOT_REACHED(); |
742 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate)); | 742 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate)); |
743 } | 743 } |
744 v8::Local<v8::Value> argv[] = { object }; | 744 v8::Local<v8::Value> argv[] = { object }; |
745 return callDebuggerMethod("getCollectionEntries", 1, argv).ToLocalChecked(); | 745 return callDebuggerMethod("getCollectionEntries", 1, argv).ToLocalChecked(); |
746 } | 746 } |
747 | 747 |
748 v8::MaybeLocal<v8::Value> V8DebuggerImpl::setFunctionVariableValue(v8::Local<v8:
:Value> functionValue, int scopeNumber, const String& variableName, v8::Local<v8
::Value> newValue) | 748 v8::MaybeLocal<v8::Value> V8DebuggerImpl::setFunctionVariableValue(v8::Local<v8:
:Value> functionValue, int scopeNumber, const String16& variableName, v8::Local<
v8::Value> newValue) |
749 { | 749 { |
750 if (m_debuggerScript.IsEmpty()) { | 750 if (m_debuggerScript.IsEmpty()) { |
751 ASSERT_NOT_REACHED(); | 751 ASSERT_NOT_REACHED(); |
752 return m_isolate->ThrowException(v8::String::NewFromUtf8(m_isolate, "Deb
ugging is not enabled.", v8::NewStringType::kNormal).ToLocalChecked()); | 752 return m_isolate->ThrowException(v8::String::NewFromUtf8(m_isolate, "Deb
ugging is not enabled.", v8::NewStringType::kNormal).ToLocalChecked()); |
753 } | 753 } |
754 | 754 |
755 v8::Local<v8::Value> argv[] = { | 755 v8::Local<v8::Value> argv[] = { |
756 functionValue, | 756 functionValue, |
757 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), | 757 v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), |
758 toV8String(m_isolate, variableName), | 758 toV8String(m_isolate, variableName), |
759 newValue | 759 newValue |
760 }; | 760 }; |
761 return callDebuggerMethod("setFunctionVariableValue", 4, argv); | 761 return callDebuggerMethod("setFunctionVariableValue", 4, argv); |
762 } | 762 } |
763 | 763 |
764 | 764 |
765 bool V8DebuggerImpl::isPaused() | 765 bool V8DebuggerImpl::isPaused() |
766 { | 766 { |
767 return !m_pausedContext.IsEmpty(); | 767 return !m_pausedContext.IsEmpty(); |
768 } | 768 } |
769 | 769 |
770 v8::Local<v8::Script> V8DebuggerImpl::compileInternalScript(v8::Local<v8::Contex
t>, v8::Local<v8::String> code, const String& fileName) | 770 v8::Local<v8::Script> V8DebuggerImpl::compileInternalScript(v8::Local<v8::Contex
t>, v8::Local<v8::String> code, const String16& fileName) |
771 { | 771 { |
772 // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at | 772 // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at |
773 // 1, whereas v8 starts at 0. | 773 // 1, whereas v8 starts at 0. |
774 v8::ScriptOrigin origin( | 774 v8::ScriptOrigin origin( |
775 toV8String(m_isolate, fileName), | 775 toV8String(m_isolate, fileName), |
776 v8::Integer::New(m_isolate, 0), | 776 v8::Integer::New(m_isolate, 0), |
777 v8::Integer::New(m_isolate, 0), | 777 v8::Integer::New(m_isolate, 0), |
778 v8::False(m_isolate), // sharable | 778 v8::False(m_isolate), // sharable |
779 v8::Local<v8::Integer>(), | 779 v8::Local<v8::Integer>(), |
780 v8::True(m_isolate), // internal | 780 v8::True(m_isolate), // internal |
781 toV8String(m_isolate, String()), // sourceMap | 781 toV8String(m_isolate, String16()), // sourceMap |
782 v8::True(m_isolate)); // opaqueresource | 782 v8::True(m_isolate)); // opaqueresource |
783 v8::ScriptCompiler::Source source(code, origin); | 783 v8::ScriptCompiler::Source source(code, origin); |
784 v8::Local<v8::Script> script; | 784 v8::Local<v8::Script> script; |
785 if (!v8::ScriptCompiler::Compile(m_isolate->GetCurrentContext(), &source, v8
::ScriptCompiler::kNoCompileOptions).ToLocal(&script)) | 785 if (!v8::ScriptCompiler::Compile(m_isolate->GetCurrentContext(), &source, v8
::ScriptCompiler::kNoCompileOptions).ToLocal(&script)) |
786 return v8::Local<v8::Script>(); | 786 return v8::Local<v8::Script>(); |
787 return script; | 787 return script; |
788 } | 788 } |
789 | 789 |
790 PassOwnPtr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTra
ce> stackTrace, size_t maxStackSize) | 790 PassOwnPtr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTra
ce> stackTrace, size_t maxStackSize) |
791 { | 791 { |
792 V8DebuggerAgentImpl* agent = getAgentForContext(m_isolate->GetCurrentContext
()); | 792 V8DebuggerAgentImpl* agent = getAgentForContext(m_isolate->GetCurrentContext
()); |
793 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize); | 793 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize); |
794 } | 794 } |
795 | 795 |
796 PassOwnPtr<V8StackTrace> V8DebuggerImpl::captureStackTrace(size_t maxStackSize) | 796 PassOwnPtr<V8StackTrace> V8DebuggerImpl::captureStackTrace(size_t maxStackSize) |
797 { | 797 { |
798 V8DebuggerAgentImpl* agent = getAgentForContext(m_isolate->GetCurrentContext
()); | 798 V8DebuggerAgentImpl* agent = getAgentForContext(m_isolate->GetCurrentContext
()); |
799 return V8StackTraceImpl::capture(agent, maxStackSize); | 799 return V8StackTraceImpl::capture(agent, maxStackSize); |
800 } | 800 } |
801 | 801 |
802 v8::Local<v8::Context> V8DebuggerImpl::regexContext() | 802 v8::Local<v8::Context> V8DebuggerImpl::regexContext() |
803 { | 803 { |
804 if (m_regexContext.IsEmpty()) | 804 if (m_regexContext.IsEmpty()) |
805 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); | 805 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); |
806 return m_regexContext.Get(m_isolate); | 806 return m_regexContext.Get(m_isolate); |
807 } | 807 } |
808 | 808 |
809 } // namespace blink | 809 } // namespace blink |
OLD | NEW |