| 388 | } |
| 389 | |
| 390 | void JsV8InspectorClient::registerModules() { |
| 391 | DEBUG_WRITE("Registering inspector modules"); |
| 392 | Isolate* isolate = isolate_; |
| 393 | auto rt = Runtime::GetRuntime(isolate); |
| 394 | v8::Locker l(isolate); |
| 395 | v8::Isolate::Scope isolate_scope(isolate); |
| 396 | v8::HandleScope handleScope(isolate); |
| 397 | auto ctx = rt->GetContext(); |
| 398 | v8::Context::Scope context_scope(ctx); |
| 399 | |
| 400 | Local<Context> context = isolate->GetEnteredOrMicrotaskContext(); |
| 401 | Local<Object> global = context->Global(); |
| 402 | Local<Object> inspectorObject = Object::New(isolate); |
| 403 | |
| 404 | bool success; |
| 405 | Local<v8::Function> func; |
| 406 | |
| 407 | // __inspector |
| 408 | success = global->Set(context, ArgConverter::ConvertToV8String(isolate, "__inspector"), inspectorObject).FromMaybe(false); |
| 409 | assert(success); |
| 410 | |
| 411 | // __registerDomainDispatcher |
| 412 | success = v8::Function::New(context, registerDomainDispatcherCallback).ToLocal(&func); |
| 413 | assert(success); |
| 414 | success = global->Set(context, ArgConverter::ConvertToV8String(isolate, "__registerDomainDispatcher"), func).FromMaybe(false); |
| 415 | assert(success); |
| 416 | |
| 417 | // __inspectorSendEvent |
| 418 | Local<External> data = External::New(isolate, this); |
| 419 | success = v8::Function::New(context, inspectorSendEventCallback, data).ToLocal(&func); |
| 420 | assert(success); |
| 421 | success = global->Set(context, ArgConverter::ConvertToV8String(isolate, "__inspectorSendEvent"), func).FromMaybe(false); |
| 422 | assert(success); |
| 423 | |
| 424 | // __inspectorTimestamp |
| 425 | success = v8::Function::New(context, inspectorTimestampCallback).ToLocal(&func); |
| 426 | assert(success); |
| 427 | success = global->Set(context, ArgConverter::ConvertToV8String(isolate, "__inspectorTimestamp"), func).FromMaybe(false); |
| 428 | assert(success); |
| 429 | |
| 430 | TryCatch tc(isolate); |
| 431 | Runtime::GetRuntime(isolate)->RunModule("inspector_modules"); |
| 432 | |
| 433 | if(tc.HasCaught()) { |
| 434 | throw NativeScriptException(tc, "Error loading inspector modules"); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | |
| 439 | void JsV8InspectorClient::InspectorIsConnectedGetterCallback(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { |
no test coverage detected