| OLD | NEW |
| 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/v8_inspector/InjectedScriptNative.h" | 7 #include "platform/v8_inspector/InjectedScriptNative.h" |
| 8 #include "platform/v8_inspector/V8Compat.h" | 8 #include "platform/v8_inspector/V8Compat.h" |
| 9 #include "platform/v8_inspector/V8Debugger.h" | 9 #include "platform/v8_inspector/V8Debugger.h" |
| 10 #include "platform/v8_inspector/V8InspectorImpl.h" | 10 #include "platform/v8_inspector/V8InspectorImpl.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 if (!subtype.isEmpty()) { | 138 if (!subtype.isEmpty()) { |
| 139 info.GetReturnValue().Set(toV8String(isolate, subtype)); | 139 info.GetReturnValue().Set(toV8String(isolate, subtype)); |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 } | 142 } |
| 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 HashSet<String16> allowedProperties; |
| 149 if (unwrapInspector(info)->debugger()->internalProperties(info.GetIsolate()-
>GetCurrentContext(), info[0]).ToLocal(&properties)) | 149 if (info[0]->IsBooleanObject() || info[0]->IsNumberObject() || |
| 150 info[0]->IsStringObject() || info[0]->IsSymbolObject()) { |
| 151 allowedProperties.add(String16("[[PrimitiveValue]]")); |
| 152 } else if (info[0]->IsPromise()) { |
| 153 allowedProperties.add(String16("[[PromiseStatus]]")); |
| 154 allowedProperties.add(String16("[[PromiseValue]]")); |
| 155 } else if (info[0]->IsGeneratorObject()) { |
| 156 allowedProperties.add(String16("[[GeneratorStatus]]")); |
| 157 } else if (info[0]->IsMapIterator() || info[0]->IsSetIterator()) { |
| 158 allowedProperties.add(String16("[[IteratorHasMore]]")); |
| 159 allowedProperties.add(String16("[[IteratorIndex]]")); |
| 160 allowedProperties.add(String16("[[IteratorKind]]")); |
| 161 allowedProperties.add(String16("[[Entries]]")); |
| 162 } else if (info[0]->IsMap() || info[0]->IsWeakMap() || info[0]->IsSet() || i
nfo[0]->IsWeakSet()) { |
| 163 allowedProperties.add(String16("[[Entries]]")); |
| 164 } |
| 165 if (!allowedProperties.size()) return; |
| 166 |
| 167 v8::Isolate* isolate = info.GetIsolate(); |
| 168 v8::Local<v8::Array> allProperties; |
| 169 if (!unwrapInspector(info)->debugger()->internalProperties(isolate->GetCurre
ntContext(), info[0]).ToLocal(&allProperties) || !allProperties->IsArray() || al
lProperties->Length() % 2 != 0) |
| 170 return; |
| 171 |
| 172 { |
| 173 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 174 v8::TryCatch tryCatch(isolate); |
| 175 v8::Isolate::DisallowJavascriptExecutionScope throwJs(isolate, v8::Isola
te::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); |
| 176 |
| 177 v8::Local<v8::Array> properties = v8::Array::New(isolate); |
| 178 if (tryCatch.HasCaught()) return; |
| 179 |
| 180 uint32_t outputIndex = 0; |
| 181 for (uint32_t i = 0; i < allProperties->Length(); i += 2) { |
| 182 v8::Local<v8::Value> key; |
| 183 if (!allProperties->Get(context, i).ToLocal(&key)) continue; |
| 184 if (tryCatch.HasCaught()) { |
| 185 tryCatch.Reset(); |
| 186 continue; |
| 187 } |
| 188 String16 keyString = toProtocolStringWithTypeCheck(key); |
| 189 if (keyString.isEmpty() || allowedProperties.find(keyString) == allo
wedProperties.end()) |
| 190 continue; |
| 191 v8::Local<v8::Value> value; |
| 192 if (!allProperties->Get(context, i + 1).ToLocal(&value)) continue; |
| 193 if (tryCatch.HasCaught()) { |
| 194 tryCatch.Reset(); |
| 195 continue; |
| 196 } |
| 197 createDataProperty(context, properties, outputIndex++, key); |
| 198 createDataProperty(context, properties, outputIndex++, value); |
| 199 } |
| 150 info.GetReturnValue().Set(properties); | 200 info.GetReturnValue().Set(properties); |
| 201 } |
| 151 } | 202 } |
| 152 | 203 |
| 153 void V8InjectedScriptHost::objectHasOwnPropertyCallback(const v8::FunctionCallba
ckInfo<v8::Value>& info) | 204 void V8InjectedScriptHost::objectHasOwnPropertyCallback(const v8::FunctionCallba
ckInfo<v8::Value>& info) |
| 154 { | 205 { |
| 155 if (info.Length() < 2 || !info[0]->IsObject() || !info[1]->IsString()) | 206 if (info.Length() < 2 || !info[0]->IsObject() || !info[1]->IsString()) |
| 156 return; | 207 return; |
| 157 bool result = info[0].As<v8::Object>()->HasOwnProperty(info.GetIsolate()->Ge
tCurrentContext(), v8::Local<v8::String>::Cast(info[1])).FromMaybe(false); | 208 bool result = info[0].As<v8::Object>()->HasOwnProperty(info.GetIsolate()->Ge
tCurrentContext(), v8::Local<v8::String>::Cast(info[1])).FromMaybe(false); |
| 158 info.GetReturnValue().Set(v8::Boolean::New(info.GetIsolate(), result)); | 209 info.GetReturnValue().Set(v8::Boolean::New(info.GetIsolate(), result)); |
| 159 } | 210 } |
| 160 | 211 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 178 NOTREACHED(); | 229 NOTREACHED(); |
| 179 return; | 230 return; |
| 180 } | 231 } |
| 181 v8::Local<v8::Object> target = info[0].As<v8::Proxy>(); | 232 v8::Local<v8::Object> target = info[0].As<v8::Proxy>(); |
| 182 while (target->IsProxy()) | 233 while (target->IsProxy()) |
| 183 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget(); | 234 target = v8::Local<v8::Proxy>::Cast(target)->GetTarget(); |
| 184 info.GetReturnValue().Set(target); | 235 info.GetReturnValue().Set(target); |
| 185 } | 236 } |
| 186 | 237 |
| 187 } // namespace v8_inspector | 238 } // namespace v8_inspector |
| OLD | NEW |