Commit 15b4b218 authored by machenbach's avatar machenbach Committed by Commit bot

Revert of [inspector] provide more usefull error message for non serializable...

Revert of [inspector] provide more usefull error message for non serializable value (patchset #3 id:40001 of https://codereview.chromium.org/2345263003/ )

Reason for revert:
Breaks https://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Linux%2064/builds/9932

See also https://github.com/v8/v8/wiki/Blink-layout-tests

Original issue's description:
> [inspector] provide more usefull error message for non serializable value
>
> Runtime.evaluate can return result by value. We need to provide more details why method call was failed.
>
> BUG=chromium:645640
> R=dgozman@chromium.org,alph@chromium.org
>
> Committed: https://crrev.com/0965b9b5df532d3aa0583966ca60794b54f56943
> Cr-Commit-Position: refs/heads/master@{#39574}

TBR=dgozman@chromium.org,alph@chromium.org,kozyatinskiy@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=chromium:645640

Review-Url: https://codereview.chromium.org/2352263003
Cr-Commit-Position: refs/heads/master@{#39580}
parent a2b8b6e7
...@@ -143,10 +143,10 @@ void InjectedScript::getProperties( ...@@ -143,10 +143,10 @@ void InjectedScript::getProperties(
*properties = Array<PropertyDescriptor>::create(); *properties = Array<PropertyDescriptor>::create();
return; return;
} }
if (hasInternalError(errorString, resultValue.IsEmpty())) return;
std::unique_ptr<protocol::Value> protocolValue = std::unique_ptr<protocol::Value> protocolValue =
toProtocolValue(errorString, context, resultValue); toProtocolValue(context, resultValue);
if (!protocolValue) return; if (hasInternalError(errorString, !protocolValue)) return;
protocol::ErrorSupport errors(errorString); protocol::ErrorSupport errors(errorString);
std::unique_ptr<Array<PropertyDescriptor>> result = std::unique_ptr<Array<PropertyDescriptor>> result =
Array<PropertyDescriptor>::parse(protocolValue.get(), &errors); Array<PropertyDescriptor>::parse(protocolValue.get(), &errors);
...@@ -177,12 +177,10 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject( ...@@ -177,12 +177,10 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(
.ToLocal(&wrappedObject)) .ToLocal(&wrappedObject))
return nullptr; return nullptr;
protocol::ErrorSupport errors; protocol::ErrorSupport errors;
std::unique_ptr<protocol::Value> protocolValue =
toProtocolValue(errorString, context, wrappedObject);
if (!protocolValue) return nullptr;
std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject =
protocol::Runtime::RemoteObject::parse(protocolValue.get(), &errors); protocol::Runtime::RemoteObject::parse(
if (!remoteObject) *errorString = errors.errors(); toProtocolValue(context, wrappedObject).get(), &errors);
if (!remoteObject) *errorString = "Object has too long reference chain";
return remoteObject; return remoteObject;
} }
...@@ -273,13 +271,10 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable( ...@@ -273,13 +271,10 @@ std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(
function.appendArgument(columns); function.appendArgument(columns);
bool hadException = false; bool hadException = false;
v8::Local<v8::Value> r = function.call(hadException); v8::Local<v8::Value> r = function.call(hadException);
if (hadException || r.IsEmpty()) return nullptr; if (hadException) return nullptr;
protocol::ErrorString errorString;
std::unique_ptr<protocol::Value> protocolValue =
toProtocolValue(&errorString, context, r);
if (!protocolValue) return nullptr;
protocol::ErrorSupport errors; protocol::ErrorSupport errors;
return protocol::Runtime::RemoteObject::parse(protocolValue.get(), &errors); return protocol::Runtime::RemoteObject::parse(
toProtocolValue(context, r).get(), &errors);
} }
bool InjectedScript::findObject(ErrorString* errorString, bool InjectedScript::findObject(ErrorString* errorString,
......
...@@ -103,8 +103,7 @@ std::unique_ptr<protocol::Value> parseJSON(const String16& string) { ...@@ -103,8 +103,7 @@ std::unique_ptr<protocol::Value> parseJSON(const String16& string) {
} // namespace protocol } // namespace protocol
std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString, std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context,
v8::Local<v8::Context> context,
v8::Local<v8::Value> value, v8::Local<v8::Value> value,
int maxDepth) { int maxDepth) {
if (value.IsEmpty()) { if (value.IsEmpty()) {
...@@ -112,10 +111,7 @@ std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString, ...@@ -112,10 +111,7 @@ std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString,
return nullptr; return nullptr;
} }
if (!maxDepth) { if (!maxDepth) return nullptr;
*errorString = "Object reference chain is too long";
return nullptr;
}
maxDepth--; maxDepth--;
if (value->IsNull() || value->IsUndefined()) return protocol::Value::null(); if (value->IsNull() || value->IsUndefined()) return protocol::Value::null();
...@@ -138,12 +134,9 @@ std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString, ...@@ -138,12 +134,9 @@ std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString,
uint32_t length = array->Length(); uint32_t length = array->Length();
for (uint32_t i = 0; i < length; i++) { for (uint32_t i = 0; i < length; i++) {
v8::Local<v8::Value> value; v8::Local<v8::Value> value;
if (!array->Get(context, i).ToLocal(&value)) { if (!array->Get(context, i).ToLocal(&value)) return nullptr;
*errorString = "Internal error";
return nullptr;
}
std::unique_ptr<protocol::Value> element = std::unique_ptr<protocol::Value> element =
toProtocolValue(errorString, context, value, maxDepth); toProtocolValue(context, value, maxDepth);
if (!element) return nullptr; if (!element) return nullptr;
inspectorArray->pushValue(std::move(element)); inspectorArray->pushValue(std::move(element));
} }
...@@ -154,17 +147,12 @@ std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString, ...@@ -154,17 +147,12 @@ std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString,
protocol::DictionaryValue::create(); protocol::DictionaryValue::create();
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
v8::Local<v8::Array> propertyNames; v8::Local<v8::Array> propertyNames;
if (!object->GetPropertyNames(context).ToLocal(&propertyNames)) { if (!object->GetPropertyNames(context).ToLocal(&propertyNames))
*errorString = "Internal error";
return nullptr; return nullptr;
}
uint32_t length = propertyNames->Length(); uint32_t length = propertyNames->Length();
for (uint32_t i = 0; i < length; i++) { for (uint32_t i = 0; i < length; i++) {
v8::Local<v8::Value> name; v8::Local<v8::Value> name;
if (!propertyNames->Get(context, i).ToLocal(&name)) { if (!propertyNames->Get(context, i).ToLocal(&name)) return nullptr;
*errorString = "Internal error";
return nullptr;
}
// FIXME(yurys): v8::Object should support GetOwnPropertyNames // FIXME(yurys): v8::Object should support GetOwnPropertyNames
if (name->IsString()) { if (name->IsString()) {
v8::Maybe<bool> hasRealNamedProperty = object->HasRealNamedProperty( v8::Maybe<bool> hasRealNamedProperty = object->HasRealNamedProperty(
...@@ -175,19 +163,16 @@ std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString, ...@@ -175,19 +163,16 @@ std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString,
v8::Local<v8::String> propertyName; v8::Local<v8::String> propertyName;
if (!name->ToString(context).ToLocal(&propertyName)) continue; if (!name->ToString(context).ToLocal(&propertyName)) continue;
v8::Local<v8::Value> property; v8::Local<v8::Value> property;
if (!object->Get(context, name).ToLocal(&property)) { if (!object->Get(context, name).ToLocal(&property)) return nullptr;
*errorString = "Internal error";
return nullptr;
}
std::unique_ptr<protocol::Value> propertyValue = std::unique_ptr<protocol::Value> propertyValue =
toProtocolValue(errorString, context, property, maxDepth); toProtocolValue(context, property, maxDepth);
if (!propertyValue) return nullptr; if (!propertyValue) return nullptr;
jsonObject->setValue(toProtocolString(propertyName), jsonObject->setValue(toProtocolString(propertyName),
std::move(propertyValue)); std::move(propertyValue));
} }
return std::move(jsonObject); return std::move(jsonObject);
} }
*errorString = "Object couldn't be returned by value"; UNREACHABLE();
return nullptr; return nullptr;
} }
......
...@@ -37,8 +37,7 @@ std::unique_ptr<protocol::Value> parseJSON(const String16& json); ...@@ -37,8 +37,7 @@ std::unique_ptr<protocol::Value> parseJSON(const String16& json);
} // namespace protocol } // namespace protocol
std::unique_ptr<protocol::Value> toProtocolValue(protocol::String* errorString, std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context>,
v8::Local<v8::Context>,
v8::Local<v8::Value>, v8::Local<v8::Value>,
int maxDepth = 1000); int maxDepth = 1000);
......
...@@ -1012,12 +1012,9 @@ std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames( ...@@ -1012,12 +1012,9 @@ std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(
return Array<CallFrame>::create(); return Array<CallFrame>::create();
} }
std::unique_ptr<protocol::Value> protocolValue =
toProtocolValue(errorString, debuggerContext, objects);
if (!protocolValue) return Array<CallFrame>::create();
protocol::ErrorSupport errorSupport; protocol::ErrorSupport errorSupport;
std::unique_ptr<Array<CallFrame>> callFrames = std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(
Array<CallFrame>::parse(protocolValue.get(), &errorSupport); toProtocolValue(debuggerContext, objects).get(), &errorSupport);
if (hasInternalError(errorString, !callFrames)) if (hasInternalError(errorString, !callFrames))
return Array<CallFrame>::create(); return Array<CallFrame>::create();
return callFrames; return callFrames;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment