OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium 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 "platform/v8_inspector/V8InjectedScriptHost.h" | 5 #include "platform/v8_inspector/V8InjectedScriptHost.h" |
6 | 6 |
7 #include "platform/inspector_protocol/String16.h" | 7 #include "platform/inspector_protocol/String16.h" |
8 #include "platform/inspector_protocol/Values.h" | 8 #include "platform/inspector_protocol/Values.h" |
9 #include "platform/v8_inspector/InjectedScript.h" | 9 #include "platform/v8_inspector/InjectedScript.h" |
10 #include "platform/v8_inspector/InjectedScriptHost.h" | 10 #include "platform/v8_inspector/InjectedScriptHost.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(context, info.Holder
()); | 319 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(context, info.Holder
()); |
320 if (!host->debugger()) | 320 if (!host->debugger()) |
321 return; | 321 return; |
322 | 322 |
323 v8::Local<v8::Script> script = host->debugger()->compileInternalScript(conte
xt, expression, String16()); | 323 v8::Local<v8::Script> script = host->debugger()->compileInternalScript(conte
xt, expression, String16()); |
324 if (script.IsEmpty()) { | 324 if (script.IsEmpty()) { |
325 setExceptionAsReturnValue(info, wrappedResult, tryCatch); | 325 setExceptionAsReturnValue(info, wrappedResult, tryCatch); |
326 return; | 326 return; |
327 } | 327 } |
328 | 328 |
329 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI
Symbol(isolate); | 329 v8::Local<v8::Symbol> scopeExtensionSymbolValue = V8Debugger::scopeExtension
Symbol(isolate); |
330 v8::Local<v8::Object> global = context->Global(); | 330 v8::Local<v8::Object> global = context->Global(); |
331 if (info.Length() >= 2 && info[1]->IsObject()) { | 331 if (info.Length() >= 2 && info[1]->IsObject()) { |
332 v8::Local<v8::Object> commandLineAPI = info[1]->ToObject(isolate); | 332 v8::Local<v8::Object> commandLineAPI = info[1]->ToObject(isolate); |
333 global->Set(commandLineAPISymbolValue, commandLineAPI); | 333 global->Set(scopeExtensionSymbolValue, commandLineAPI); |
334 } | 334 } |
335 | 335 |
336 v8::MaybeLocal<v8::Value> result = host->debugger()->runCompiledScript(conte
xt, script); | 336 v8::MaybeLocal<v8::Value> result = host->debugger()->runCompiledScript(conte
xt, script); |
337 if (result.IsEmpty()) { | 337 if (result.IsEmpty()) { |
338 global->Delete(context, commandLineAPISymbolValue); | 338 global->Delete(context, scopeExtensionSymbolValue); |
339 setExceptionAsReturnValue(info, wrappedResult, tryCatch); | 339 setExceptionAsReturnValue(info, wrappedResult, tryCatch); |
340 return; | 340 return; |
341 } | 341 } |
342 | 342 |
343 global->Delete(context, commandLineAPISymbolValue); | 343 global->Delete(context, scopeExtensionSymbolValue); |
344 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result.ToLoca
lChecked()); | 344 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result.ToLoca
lChecked()); |
345 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), v8:
:Undefined(isolate)); | 345 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), v8:
:Undefined(isolate)); |
346 v8SetReturnValue(info, wrappedResult); | 346 v8SetReturnValue(info, wrappedResult); |
347 } | 347 } |
348 | 348 |
349 static bool getFunctionLocation(const v8::FunctionCallbackInfo<v8::Value>& info,
String16* scriptId, int* lineNumber, int* columnNumber) | 349 static bool getFunctionLocation(const v8::FunctionCallbackInfo<v8::Value>& info,
String16* scriptId, int* lineNumber, int* columnNumber) |
350 { | 350 { |
351 if (info.Length() < 1 || !info[0]->IsFunction()) | 351 if (info.Length() < 1 || !info[0]->IsFunction()) |
352 return false; | 352 return false; |
353 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(info[0]); | 353 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(info[0]); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 return; | 502 return; |
503 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec
tedScriptHost(info.Holder()); | 503 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec
tedScriptHost(info.Holder()); |
504 if (!injectedScriptNative) | 504 if (!injectedScriptNative) |
505 return; | 505 return; |
506 int id = info[0].As<v8::Int32>()->Value(); | 506 int id = info[0].As<v8::Int32>()->Value(); |
507 String16 groupName = injectedScriptNative->groupName(id); | 507 String16 groupName = injectedScriptNative->groupName(id); |
508 if (!groupName.isEmpty()) | 508 if (!groupName.isEmpty()) |
509 info.GetReturnValue().Set(toV8String(info.GetIsolate(), groupName)); | 509 info.GetReturnValue().Set(toV8String(info.GetIsolate(), groupName)); |
510 } | 510 } |
511 | 511 |
512 v8::Local<v8::Symbol> V8Debugger::commandLineAPISymbol(v8::Isolate* isolate) | 512 v8::Local<v8::Symbol> V8Debugger::scopeExtensionSymbol(v8::Isolate* isolate) |
513 { | 513 { |
514 return v8::Symbol::ForApi(isolate, toV8StringInternalized(isolate, "commandL
ineAPI")); | 514 return v8::Symbol::ForApi(isolate, toV8StringInternalized(isolate, "scopeExt
ension")); |
515 } | 515 } |
516 | 516 |
517 bool V8Debugger::isCommandLineAPIMethod(const String16& name) | 517 bool V8Debugger::isCommandLineAPIMethod(const String16& name) |
518 { | 518 { |
519 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, methods, ()); | 519 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, methods, ()); |
520 if (methods.size() == 0) { | 520 if (methods.size() == 0) { |
521 const char* members[] = { "$", "$$", "$x", "dir", "dirxml", "keys", "val
ues", "profile", "profileEnd", | 521 const char* members[] = { "$", "$$", "$x", "dir", "dirxml", "keys", "val
ues", "profile", "profileEnd", |
522 "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "get
EventListeners", | 522 "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "get
EventListeners", |
523 "debug", "undebug", "monitor", "unmonitor", "table", "$_" }; | 523 "debug", "undebug", "monitor", "unmonitor", "table", "$_" }; |
524 for (size_t i = 0; i < sizeof(members) / sizeof(const char*); ++i) | 524 for (size_t i = 0; i < sizeof(members) / sizeof(const char*); ++i) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 { | 584 { |
585 return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host); | 585 return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host); |
586 } | 586 } |
587 | 587 |
588 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Context> context,
v8::Local<v8::Object> object) | 588 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Context> context,
v8::Local<v8::Object> object) |
589 { | 589 { |
590 return InjectedScriptHostWrapper::unwrap(context, object); | 590 return InjectedScriptHostWrapper::unwrap(context, object); |
591 } | 591 } |
592 | 592 |
593 } // namespace blink | 593 } // namespace blink |
OLD | NEW |