| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project 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 "src/inspector/v8-injected-script-host.h" | 5 #include "src/inspector/v8-injected-script-host.h" |
| 6 | 6 |
| 7 #include "src/base/macros.h" | 7 #include "src/base/macros.h" |
| 8 #include "src/inspector/injected-script-native.h" | 8 #include "src/inspector/injected-script-native.h" |
| 9 #include "src/inspector/string-util.h" | 9 #include "src/inspector/string-util.h" |
| 10 #include "src/inspector/v8-debugger.h" | 10 #include "src/inspector/v8-debugger.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate); | 51 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate); |
| 52 bool success = injectedScriptHost->SetPrototype(context, v8::Null(isolate)) | 52 bool success = injectedScriptHost->SetPrototype(context, v8::Null(isolate)) |
| 53 .FromMaybe(false); | 53 .FromMaybe(false); |
| 54 DCHECK(success); | 54 DCHECK(success); |
| 55 USE(success); | 55 USE(success); |
| 56 v8::Local<v8::External> debuggerExternal = | 56 v8::Local<v8::External> debuggerExternal = |
| 57 v8::External::New(isolate, inspector); | 57 v8::External::New(isolate, inspector); |
| 58 setFunctionProperty(context, injectedScriptHost, "nullifyPrototype", | 58 setFunctionProperty(context, injectedScriptHost, "nullifyPrototype", |
| 59 V8InjectedScriptHost::nullifyPrototypeCallback, | 59 V8InjectedScriptHost::nullifyPrototypeCallback, |
| 60 debuggerExternal); | 60 debuggerExternal); |
| 61 setFunctionProperty(context, injectedScriptHost, "getProperty", |
| 62 V8InjectedScriptHost::getPropertyCallback, |
| 63 debuggerExternal); |
| 61 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", | 64 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", |
| 62 V8InjectedScriptHost::internalConstructorNameCallback, | 65 V8InjectedScriptHost::internalConstructorNameCallback, |
| 63 debuggerExternal); | 66 debuggerExternal); |
| 64 setFunctionProperty( | 67 setFunctionProperty( |
| 65 context, injectedScriptHost, "formatAccessorsAsProperties", | 68 context, injectedScriptHost, "formatAccessorsAsProperties", |
| 66 V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); | 69 V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); |
| 67 setFunctionProperty(context, injectedScriptHost, "subtype", | 70 setFunctionProperty(context, injectedScriptHost, "subtype", |
| 68 V8InjectedScriptHost::subtypeCallback, debuggerExternal); | 71 V8InjectedScriptHost::subtypeCallback, debuggerExternal); |
| 69 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", | 72 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", |
| 70 V8InjectedScriptHost::getInternalPropertiesCallback, | 73 V8InjectedScriptHost::getInternalPropertiesCallback, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 83 void V8InjectedScriptHost::nullifyPrototypeCallback( | 86 void V8InjectedScriptHost::nullifyPrototypeCallback( |
| 84 const v8::FunctionCallbackInfo<v8::Value>& info) { | 87 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 85 CHECK(info.Length() == 1 && info[0]->IsObject()); | 88 CHECK(info.Length() == 1 && info[0]->IsObject()); |
| 86 v8::Isolate* isolate = info.GetIsolate(); | 89 v8::Isolate* isolate = info.GetIsolate(); |
| 87 info[0] | 90 info[0] |
| 88 .As<v8::Object>() | 91 .As<v8::Object>() |
| 89 ->SetPrototype(isolate->GetCurrentContext(), v8::Null(isolate)) | 92 ->SetPrototype(isolate->GetCurrentContext(), v8::Null(isolate)) |
| 90 .ToChecked(); | 93 .ToChecked(); |
| 91 } | 94 } |
| 92 | 95 |
| 96 void V8InjectedScriptHost::getPropertyCallback( |
| 97 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 98 CHECK(info.Length() == 2 && info[1]->IsString()); |
| 99 if (!info[0]->IsObject()) return; |
| 100 v8::Isolate* isolate = info.GetIsolate(); |
| 101 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 102 v8::TryCatch tryCatch(isolate); |
| 103 v8::Isolate::DisallowJavascriptExecutionScope throwJs( |
| 104 isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); |
| 105 v8::Local<v8::Value> property; |
| 106 if (info[0] |
| 107 .As<v8::Object>() |
| 108 ->Get(context, v8::Local<v8::String>::Cast(info[1])) |
| 109 .ToLocal(&property)) { |
| 110 info.GetReturnValue().Set(property); |
| 111 } |
| 112 } |
| 113 |
| 93 void V8InjectedScriptHost::internalConstructorNameCallback( | 114 void V8InjectedScriptHost::internalConstructorNameCallback( |
| 94 const v8::FunctionCallbackInfo<v8::Value>& info) { | 115 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 95 if (info.Length() < 1 || !info[0]->IsObject()) return; | 116 if (info.Length() < 1 || !info[0]->IsObject()) return; |
| 96 | 117 |
| 97 v8::Local<v8::Object> object = info[0].As<v8::Object>(); | 118 v8::Local<v8::Object> object = info[0].As<v8::Object>(); |
| 98 info.GetReturnValue().Set(object->GetConstructorName()); | 119 info.GetReturnValue().Set(object->GetConstructorName()); |
| 99 } | 120 } |
| 100 | 121 |
| 101 void V8InjectedScriptHost::formatAccessorsAsProperties( | 122 void V8InjectedScriptHost::formatAccessorsAsProperties( |
| 102 const v8::FunctionCallbackInfo<v8::Value>& info) { | 123 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 UNREACHABLE(); | 306 UNREACHABLE(); |
| 286 return; | 307 return; |
| 287 } | 308 } |
| 288 v8::Local<v8::Object> target = info[0].As<v8::Proxy>(); | 309 v8::Local<v8::Object> target = info[0].As<v8::Proxy>(); |
| 289 while (target->IsProxy()) | 310 while (target->IsProxy()) |
| 290 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget(); | 311 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget(); |
| 291 info.GetReturnValue().Set(target); | 312 info.GetReturnValue().Set(target); |
| 292 } | 313 } |
| 293 | 314 |
| 294 } // namespace v8_inspector | 315 } // namespace v8_inspector |
| OLD | NEW |