Chromium Code Reviews| Index: src/inspector/v8-injected-script-host.cc |
| diff --git a/src/inspector/v8-injected-script-host.cc b/src/inspector/v8-injected-script-host.cc |
| index dc41ef8631febeb25c09de2400d69ba15518ec73..f620f6f42c0411d66875123918b4ee3ba52449f1 100644 |
| --- a/src/inspector/v8-injected-script-host.cc |
| +++ b/src/inspector/v8-injected-script-host.cc |
| @@ -166,12 +166,61 @@ void V8InjectedScriptHost::subtypeCallback( |
| void V8InjectedScriptHost::getInternalPropertiesCallback( |
| const v8::FunctionCallbackInfo<v8::Value>& info) { |
| if (info.Length() < 1) return; |
| - v8::Local<v8::Array> properties; |
| - if (unwrapInspector(info) |
| - ->debugger() |
| - ->internalProperties(info.GetIsolate()->GetCurrentContext(), info[0]) |
| - .ToLocal(&properties)) |
| - info.GetReturnValue().Set(properties); |
| + |
| + std::unordered_set<String16> allowedProperties; |
| + if (info[0]->IsBooleanObject() || info[0]->IsNumberObject() || |
| + info[0]->IsStringObject() || info[0]->IsSymbolObject()) { |
| + allowedProperties.insert(String16("[[PrimitiveValue]]")); |
| + } else if (info[0]->IsPromise()) { |
| + allowedProperties.insert(String16("[[PromiseStatus]]")); |
| + allowedProperties.insert(String16("[[PromiseValue]]")); |
| + } else if (info[0]->IsGeneratorObject()) { |
| + allowedProperties.insert(String16("[[GeneratorStatus]]")); |
| + } else if (info[0]->IsMapIterator() || info[0]->IsSetIterator()) { |
| + allowedProperties.insert(String16("[[IteratorHasMore]]")); |
| + allowedProperties.insert(String16("[[IteratorIndex]]")); |
| + allowedProperties.insert(String16("[[IteratorKind]]")); |
| + allowedProperties.insert(String16("[[Entries]]")); |
| + } else if (info[0]->IsMap() || info[0]->IsWeakMap() || info[0]->IsSet() || |
| + info[0]->IsWeakSet()) { |
| + allowedProperties.insert(String16("[[Entries]]")); |
| + } |
| + if (!allowedProperties.size()) return; |
| + |
| + v8::Isolate* isolate = info.GetIsolate(); |
| + v8::Local<v8::Array> allProperties; |
| + if (!unwrapInspector(info) |
| + ->debugger() |
| + ->internalProperties(isolate->GetCurrentContext(), info[0]) |
| + .ToLocal(&allProperties) || |
| + !allProperties->IsArray() || allProperties->Length() % 2 != 0) |
| + return; |
| + |
| + v8::Local<v8::Array> properties = v8::Array::New(isolate); |
|
dgozman
2016/10/07 00:00:18
Let's put this under throwJs.
kozy
2016/10/07 00:20:30
Done.
|
| + { |
| + v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| + v8::TryCatch tryCatch(isolate); |
| + v8::Isolate::DisallowJavascriptExecutionScope throwJs( |
| + isolate, |
| + v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); |
| + |
| + uint32_t outputIndex = 0; |
| + for (uint32_t i = 0; i < allProperties->Length(); i += 2) { |
| + v8::Local<v8::Value> key; |
| + if (!allProperties->Get(context, i).ToLocal(&key)) continue; |
| + if (tryCatch.HasCaught()) return; |
|
dgozman
2016/10/07 00:00:18
continue
kozy
2016/10/07 00:20:30
Done.
|
| + String16 keyString = toProtocolStringWithTypeCheck(key); |
| + if (keyString.isEmpty() || |
| + allowedProperties.find(keyString) == allowedProperties.end()) |
| + continue; |
| + v8::Local<v8::Value> value; |
| + if (!allProperties->Get(context, i + 1).ToLocal(&value)) continue; |
| + if (tryCatch.HasCaught()) return; |
|
dgozman
2016/10/07 00:00:18
continue
kozy
2016/10/07 00:20:30
Done.
|
| + createDataProperty(context, properties, outputIndex++, key); |
| + createDataProperty(context, properties, outputIndex++, value); |
| + } |
| + } |
| + info.GetReturnValue().Set(properties); |
| } |
| void V8InjectedScriptHost::objectHasOwnPropertyCallback( |