aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/inspector/value-mirror.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/inspector/value-mirror.cc')
-rw-r--r--deps/v8/src/inspector/value-mirror.cc73
1 files changed, 69 insertions, 4 deletions
diff --git a/deps/v8/src/inspector/value-mirror.cc b/deps/v8/src/inspector/value-mirror.cc
index aac6481828..8feb97dd54 100644
--- a/deps/v8/src/inspector/value-mirror.cc
+++ b/deps/v8/src/inspector/value-mirror.cc
@@ -56,10 +56,14 @@ Response toProtocolValue(v8::Local<v8::Context> context,
}
if (value->IsNumber()) {
double doubleValue = value.As<v8::Number>()->Value();
- int intValue = static_cast<int>(doubleValue);
- if (intValue == doubleValue) {
- *result = protocol::FundamentalValue::create(intValue);
- return Response::OK();
+ if (doubleValue >= std::numeric_limits<int>::min() &&
+ doubleValue <= std::numeric_limits<int>::max() &&
+ bit_cast<int64_t>(doubleValue) != bit_cast<int64_t>(-0.0)) {
+ int intValue = static_cast<int>(doubleValue);
+ if (intValue == doubleValue) {
+ *result = protocol::FundamentalValue::create(intValue);
+ return Response::OK();
+ }
}
*result = protocol::FundamentalValue::create(doubleValue);
return Response::OK();
@@ -805,6 +809,63 @@ void getInternalPropertiesForPreview(
}
}
+void getPrivateFieldsForPreview(v8::Local<v8::Context> context,
+ v8::Local<v8::Object> object, int* nameLimit,
+ bool* overflow,
+ protocol::Array<PropertyPreview>* properties) {
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::MicrotasksScope microtasksScope(isolate,
+ v8::MicrotasksScope::kDoNotRunMicrotasks);
+ v8::TryCatch tryCatch(isolate);
+ v8::Local<v8::Array> privateFields;
+
+ if (!v8::debug::GetPrivateFields(context, object).ToLocal(&privateFields)) {
+ return;
+ }
+
+ for (uint32_t i = 0; i < privateFields->Length(); i += 2) {
+ v8::Local<v8::Data> name;
+ if (!privateFields->Get(context, i).ToLocal(&name)) {
+ tryCatch.Reset();
+ continue;
+ }
+
+ // Weirdly, v8::Private is set to be a subclass of v8::Data and
+ // not v8::Value, meaning, we first need to upcast to v8::Data
+ // and then downcast to v8::Private. Changing the hierarchy is a
+ // breaking change now. Not sure if that's possible.
+ //
+ // TODO(gsathya): Add an IsPrivate method to the v8::Private and
+ // assert here.
+ v8::Local<v8::Private> private_field = v8::Local<v8::Private>::Cast(name);
+ v8::Local<v8::Value> private_name = private_field->Name();
+ CHECK(!private_name->IsUndefined());
+
+ v8::Local<v8::Value> value;
+ if (!privateFields->Get(context, i + 1).ToLocal(&value)) {
+ tryCatch.Reset();
+ continue;
+ }
+
+ auto wrapper = ValueMirror::create(context, value);
+ if (wrapper) {
+ std::unique_ptr<PropertyPreview> propertyPreview;
+ wrapper->buildPropertyPreview(
+ context,
+ toProtocolStringWithTypeCheck(context->GetIsolate(), private_name),
+ &propertyPreview);
+ if (propertyPreview) {
+ if (!*nameLimit) {
+ *overflow = true;
+ return;
+ }
+ --*nameLimit;
+ properties->addItem(std::move(propertyPreview));
+ }
+ }
+ }
+}
+
class ObjectMirror final : public ValueMirror {
public:
ObjectMirror(v8::Local<v8::Value> value, const String16& description)
@@ -895,6 +956,7 @@ class ObjectMirror final : public ValueMirror {
v8::Local<v8::Value> value = m_value;
while (value->IsProxy()) value = value.As<v8::Proxy>()->GetTarget();
+
if (value->IsObject() && !value->IsProxy()) {
v8::Local<v8::Object> objectForPreview = value.As<v8::Object>();
std::vector<InternalPropertyMirror> internalProperties;
@@ -909,6 +971,9 @@ class ObjectMirror final : public ValueMirror {
}
}
+ getPrivateFieldsForPreview(context, objectForPreview, nameLimit,
+ &overflow, properties.get());
+
std::vector<PropertyMirror> mirrors;
if (getPropertiesForPreview(context, objectForPreview, nameLimit,
indexLimit, &overflow, &mirrors)) {