| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 v8::Local<v8::Object> V8InjectedScriptHost::create( | 48 v8::Local<v8::Object> V8InjectedScriptHost::create( |
| 49 v8::Local<v8::Context> context, V8InspectorImpl* inspector) { | 49 v8::Local<v8::Context> context, V8InspectorImpl* inspector) { |
| 50 v8::Isolate* isolate = inspector->isolate(); | 50 v8::Isolate* isolate = inspector->isolate(); |
| 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", |
| 59 V8InjectedScriptHost::nullifyPrototypeCallback, |
| 60 debuggerExternal); |
| 58 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", | 61 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", |
| 59 V8InjectedScriptHost::internalConstructorNameCallback, | 62 V8InjectedScriptHost::internalConstructorNameCallback, |
| 60 debuggerExternal); | 63 debuggerExternal); |
| 61 setFunctionProperty( | 64 setFunctionProperty( |
| 62 context, injectedScriptHost, "formatAccessorsAsProperties", | 65 context, injectedScriptHost, "formatAccessorsAsProperties", |
| 63 V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); | 66 V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); |
| 64 setFunctionProperty(context, injectedScriptHost, "subtype", | 67 setFunctionProperty(context, injectedScriptHost, "subtype", |
| 65 V8InjectedScriptHost::subtypeCallback, debuggerExternal); | 68 V8InjectedScriptHost::subtypeCallback, debuggerExternal); |
| 66 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", | 69 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", |
| 67 V8InjectedScriptHost::getInternalPropertiesCallback, | 70 V8InjectedScriptHost::getInternalPropertiesCallback, |
| 68 debuggerExternal); | 71 debuggerExternal); |
| 69 setFunctionProperty(context, injectedScriptHost, "objectHasOwnProperty", | 72 setFunctionProperty(context, injectedScriptHost, "objectHasOwnProperty", |
| 70 V8InjectedScriptHost::objectHasOwnPropertyCallback, | 73 V8InjectedScriptHost::objectHasOwnPropertyCallback, |
| 71 debuggerExternal); | 74 debuggerExternal); |
| 72 setFunctionProperty(context, injectedScriptHost, "bind", | 75 setFunctionProperty(context, injectedScriptHost, "bind", |
| 73 V8InjectedScriptHost::bindCallback, debuggerExternal); | 76 V8InjectedScriptHost::bindCallback, debuggerExternal); |
| 74 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", | 77 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", |
| 75 V8InjectedScriptHost::proxyTargetValueCallback, | 78 V8InjectedScriptHost::proxyTargetValueCallback, |
| 76 debuggerExternal); | 79 debuggerExternal); |
| 77 return injectedScriptHost; | 80 return injectedScriptHost; |
| 78 } | 81 } |
| 79 | 82 |
| 83 void V8InjectedScriptHost::nullifyPrototypeCallback( |
| 84 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 85 CHECK(info.Length() == 1 && info[0]->IsObject()); |
| 86 v8::Isolate* isolate = info.GetIsolate(); |
| 87 info[0] |
| 88 .As<v8::Object>() |
| 89 ->SetPrototype(isolate->GetCurrentContext(), v8::Null(isolate)) |
| 90 .ToChecked(); |
| 91 } |
| 92 |
| 80 void V8InjectedScriptHost::internalConstructorNameCallback( | 93 void V8InjectedScriptHost::internalConstructorNameCallback( |
| 81 const v8::FunctionCallbackInfo<v8::Value>& info) { | 94 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 82 if (info.Length() < 1 || !info[0]->IsObject()) return; | 95 if (info.Length() < 1 || !info[0]->IsObject()) return; |
| 83 | 96 |
| 84 v8::Local<v8::Object> object = info[0].As<v8::Object>(); | 97 v8::Local<v8::Object> object = info[0].As<v8::Object>(); |
| 85 info.GetReturnValue().Set(object->GetConstructorName()); | 98 info.GetReturnValue().Set(object->GetConstructorName()); |
| 86 } | 99 } |
| 87 | 100 |
| 88 void V8InjectedScriptHost::formatAccessorsAsProperties( | 101 void V8InjectedScriptHost::formatAccessorsAsProperties( |
| 89 const v8::FunctionCallbackInfo<v8::Value>& info) { | 102 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 UNREACHABLE(); | 285 UNREACHABLE(); |
| 273 return; | 286 return; |
| 274 } | 287 } |
| 275 v8::Local<v8::Object> target = info[0].As<v8::Proxy>(); | 288 v8::Local<v8::Object> target = info[0].As<v8::Proxy>(); |
| 276 while (target->IsProxy()) | 289 while (target->IsProxy()) |
| 277 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget(); | 290 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget(); |
| 278 info.GetReturnValue().Set(target); | 291 info.GetReturnValue().Set(target); |
| 279 } | 292 } |
| 280 | 293 |
| 281 } // namespace v8_inspector | 294 } // namespace v8_inspector |
| OLD | NEW |