Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: src/inspector/v8-injected-script-host.cc

Issue 2767323002: [inspector] better isArrayLike for injected-script-source.js (Closed)
Patch Set: length on array should be own property Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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, "get",
62 V8InjectedScriptHost::getCallback, debuggerExternal);
61 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", 63 setFunctionProperty(context, injectedScriptHost, "internalConstructorName",
62 V8InjectedScriptHost::internalConstructorNameCallback, 64 V8InjectedScriptHost::internalConstructorNameCallback,
63 debuggerExternal); 65 debuggerExternal);
64 setFunctionProperty( 66 setFunctionProperty(
65 context, injectedScriptHost, "formatAccessorsAsProperties", 67 context, injectedScriptHost, "formatAccessorsAsProperties",
66 V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); 68 V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal);
67 setFunctionProperty(context, injectedScriptHost, "subtype", 69 setFunctionProperty(context, injectedScriptHost, "subtype",
68 V8InjectedScriptHost::subtypeCallback, debuggerExternal); 70 V8InjectedScriptHost::subtypeCallback, debuggerExternal);
69 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", 71 setFunctionProperty(context, injectedScriptHost, "getInternalProperties",
70 V8InjectedScriptHost::getInternalPropertiesCallback, 72 V8InjectedScriptHost::getInternalPropertiesCallback,
(...skipping 12 matching lines...) Expand all
83 void V8InjectedScriptHost::nullifyPrototypeCallback( 85 void V8InjectedScriptHost::nullifyPrototypeCallback(
84 const v8::FunctionCallbackInfo<v8::Value>& info) { 86 const v8::FunctionCallbackInfo<v8::Value>& info) {
85 CHECK(info.Length() == 1 && info[0]->IsObject()); 87 CHECK(info.Length() == 1 && info[0]->IsObject());
86 v8::Isolate* isolate = info.GetIsolate(); 88 v8::Isolate* isolate = info.GetIsolate();
87 info[0] 89 info[0]
88 .As<v8::Object>() 90 .As<v8::Object>()
89 ->SetPrototype(isolate->GetCurrentContext(), v8::Null(isolate)) 91 ->SetPrototype(isolate->GetCurrentContext(), v8::Null(isolate))
90 .ToChecked(); 92 .ToChecked();
91 } 93 }
92 94
95 void V8InjectedScriptHost::getCallback(
96 const v8::FunctionCallbackInfo<v8::Value>& info) {
97 CHECK(info.Length() == 2 && info[1]->IsString());
98 if (!info[0]->IsObject()) return;
99 v8::Isolate* isolate = info.GetIsolate();
100 v8::Local<v8::Context> context = isolate->GetCurrentContext();
101 v8::TryCatch tryCatch(isolate);
102 v8::Isolate::DisallowJavascriptExecutionScope throwJs(
103 isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE);
104 v8::Local<v8::Value> property;
105 if (info[0]
106 .As<v8::Object>()
107 ->Get(context, v8::Local<v8::String>::Cast(info[1]))
108 .ToLocal(&property)) {
109 info.GetReturnValue().Set(property);
dgozman 2017/03/23 21:10:20 So, do we return undefined in case of JS execution
kozy 2017/03/24 00:40:37 yes, we do, in current use cases it looks like exp
110 }
111 }
112
93 void V8InjectedScriptHost::internalConstructorNameCallback( 113 void V8InjectedScriptHost::internalConstructorNameCallback(
94 const v8::FunctionCallbackInfo<v8::Value>& info) { 114 const v8::FunctionCallbackInfo<v8::Value>& info) {
95 if (info.Length() < 1 || !info[0]->IsObject()) return; 115 if (info.Length() < 1 || !info[0]->IsObject()) return;
96 116
97 v8::Local<v8::Object> object = info[0].As<v8::Object>(); 117 v8::Local<v8::Object> object = info[0].As<v8::Object>();
98 info.GetReturnValue().Set(object->GetConstructorName()); 118 info.GetReturnValue().Set(object->GetConstructorName());
99 } 119 }
100 120
101 void V8InjectedScriptHost::formatAccessorsAsProperties( 121 void V8InjectedScriptHost::formatAccessorsAsProperties(
102 const v8::FunctionCallbackInfo<v8::Value>& info) { 122 const v8::FunctionCallbackInfo<v8::Value>& info) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 UNREACHABLE(); 305 UNREACHABLE();
286 return; 306 return;
287 } 307 }
288 v8::Local<v8::Object> target = info[0].As<v8::Proxy>(); 308 v8::Local<v8::Object> target = info[0].As<v8::Proxy>();
289 while (target->IsProxy()) 309 while (target->IsProxy())
290 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget(); 310 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget();
291 info.GetReturnValue().Set(target); 311 info.GetReturnValue().Set(target);
292 } 312 }
293 313
294 } // namespace v8_inspector 314 } // namespace v8_inspector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698