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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp

Issue 2190353004: [DevTools] Replace InjectedScriptHost.suppressWarningsAndCallFunction with hasOwnProperty. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 4 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 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/v8_inspector/InjectedScriptNative.h" 8 #include "platform/v8_inspector/InjectedScriptNative.h"
9 #include "platform/v8_inspector/V8Compat.h" 9 #include "platform/v8_inspector/V8Compat.h"
10 #include "platform/v8_inspector/V8DebuggerImpl.h" 10 #include "platform/v8_inspector/V8DebuggerImpl.h"
(...skipping 30 matching lines...) Expand all
41 v8::Local<v8::Object> V8InjectedScriptHost::create(v8::Local<v8::Context> contex t, V8DebuggerImpl* debugger) 41 v8::Local<v8::Object> V8InjectedScriptHost::create(v8::Local<v8::Context> contex t, V8DebuggerImpl* debugger)
42 { 42 {
43 v8::Isolate* isolate = debugger->isolate(); 43 v8::Isolate* isolate = debugger->isolate();
44 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate); 44 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate);
45 v8::Local<v8::External> debuggerExternal = v8::External::New(isolate, debugg er); 45 v8::Local<v8::External> debuggerExternal = v8::External::New(isolate, debugg er);
46 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", V8InjectedScriptHost::internalConstructorNameCallback, debuggerExternal); 46 setFunctionProperty(context, injectedScriptHost, "internalConstructorName", V8InjectedScriptHost::internalConstructorNameCallback, debuggerExternal);
47 setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsPropertie s", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); 47 setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsPropertie s", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal);
48 setFunctionProperty(context, injectedScriptHost, "isTypedArray", V8InjectedS criptHost::isTypedArrayCallback, debuggerExternal); 48 setFunctionProperty(context, injectedScriptHost, "isTypedArray", V8InjectedS criptHost::isTypedArrayCallback, debuggerExternal);
49 setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScript Host::subtypeCallback, debuggerExternal); 49 setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScript Host::subtypeCallback, debuggerExternal);
50 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8 InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal); 50 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8 InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal);
51 setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFun ction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerE xternal); 51 setFunctionProperty(context, injectedScriptHost, "objectHasOwnProperty", V8I njectedScriptHost::objectHasOwnPropertyCallback, debuggerExternal);
52 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos t::bindCallback, debuggerExternal); 52 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos t::bindCallback, debuggerExternal);
53 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8Injec tedScriptHost::proxyTargetValueCallback, debuggerExternal); 53 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8Injec tedScriptHost::proxyTargetValueCallback, debuggerExternal);
54 setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScri ptHost::prototypeCallback, debuggerExternal); 54 setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScri ptHost::prototypeCallback, debuggerExternal);
55 return injectedScriptHost; 55 return injectedScriptHost;
56 } 56 }
57 57
58 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal lbackInfo<v8::Value>& info) 58 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal lbackInfo<v8::Value>& info)
59 { 59 {
60 if (info.Length() < 1 || !info[0]->IsObject()) 60 if (info.Length() < 1 || !info[0]->IsObject())
61 return; 61 return;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb ackInfo<v8::Value>& info) 144 void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb ackInfo<v8::Value>& info)
145 { 145 {
146 if (info.Length() < 1) 146 if (info.Length() < 1)
147 return; 147 return;
148 v8::Local<v8::Array> properties; 148 v8::Local<v8::Array> properties;
149 if (unwrapDebugger(info)->internalProperties(info.GetIsolate()->GetCurrentCo ntext(), info[0]).ToLocal(&properties)) 149 if (unwrapDebugger(info)->internalProperties(info.GetIsolate()->GetCurrentCo ntext(), info[0]).ToLocal(&properties))
150 info.GetReturnValue().Set(properties); 150 info.GetReturnValue().Set(properties);
151 } 151 }
152 152
153 void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun ctionCallbackInfo<v8::Value>& info) 153 void V8InjectedScriptHost::objectHasOwnPropertyCallback(const v8::FunctionCallba ckInfo<v8::Value>& info)
154 { 154 {
155 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) { 155 if (info.Length() < 2 || !info[0]->IsObject() || !info[1]->IsString())
156 NOTREACHED();
157 return; 156 return;
158 } 157 bool result = info[0].As<v8::Object>()->HasOwnProperty(info.GetIsolate()->Ge tCurrentContext(), v8::Local<v8::String>::Cast(info[1])).FromMaybe(false);
159 if (info.Length() > 2 && (!info[2]->IsArray() && !info[2]->IsUndefined())) { 158 info.GetReturnValue().Set(v8::Boolean::New(info.GetIsolate(), result));
160 NOTREACHED();
161 return;
162 }
163
164 v8::Isolate* isolate = info.GetIsolate();
165 v8::Local<v8::Context> context = isolate->GetCurrentContext();
166
167 v8::Local<v8::Function> function = info[0].As<v8::Function>();
168 v8::Local<v8::Value> receiver = info[1];
169 std::unique_ptr<v8::Local<v8::Value>[]> argv = nullptr;
170 size_t argc = 0;
171
172 if (info.Length() > 2 && info[2]->IsArray()) {
173 v8::Local<v8::Array> arguments = info[2].As<v8::Array>();
174 argc = arguments->Length();
175 argv.reset(new v8::Local<v8::Value>[argc]);
176 for (size_t i = 0; i < argc; ++i) {
177 if (!arguments->Get(context, i).ToLocal(&argv[i]))
178 return;
179 }
180 }
181
182 V8DebuggerImpl* debugger = unwrapDebugger(info);
183 int contextGroupId = V8DebuggerImpl::getGroupId(context);
184 if (contextGroupId)
185 debugger->client()->muteWarningsAndDeprecations(contextGroupId);
186
187 v8::MicrotasksScope microtasks(isolate, v8::MicrotasksScope::kDoNotRunMicrot asks);
188 v8::Local<v8::Value> result;
189 if (function->Call(context, receiver, argc, argv.get()).ToLocal(&result))
190 info.GetReturnValue().Set(result);
191
192 if (contextGroupId)
193 debugger->client()->unmuteWarningsAndDeprecations(contextGroupId);
194 } 159 }
195 160
196 void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo<v8::Value >& info) 161 void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo<v8::Value >& info)
197 { 162 {
198 if (info.Length() < 2 || !info[1]->IsString()) 163 if (info.Length() < 2 || !info[1]->IsString())
199 return; 164 return;
200 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder()); 165 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder());
201 if (!injectedScriptNative) 166 if (!injectedScriptNative)
202 return; 167 return;
203 168
(...skipping 15 matching lines...) Expand all
219 info.GetReturnValue().Set(target); 184 info.GetReturnValue().Set(target);
220 } 185 }
221 186
222 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8:: Value>& info) 187 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8:: Value>& info)
223 { 188 {
224 DCHECK(info.Length() > 0 && info[0]->IsObject()); 189 DCHECK(info.Length() > 0 && info[0]->IsObject());
225 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); 190 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype());
226 } 191 }
227 192
228 } // namespace blink 193 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698