diff --git a/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp b/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp index 4d9152423abf3..63893bdde56e7 100644 --- a/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp +++ b/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp @@ -66,6 +66,13 @@ static RefPtr jsToInspectorValue(JSC::JSGlobalObject* globalObject, if (value.isString()) return JSON::Value::create(asString(value)->value(globalObject).data); + // BigInt and Symbol have no JSON representation. They can reach this point + // when Runtime.evaluate / callFunctionOn is invoked with returnByValue on a + // result that holds one (e.g. `[1n]` or `Symbol()`), so report the value as + // not representable rather than hitting ASSERT_NOT_REACHED below. + if (value.isBigInt() || value.isSymbol()) + return nullptr; + if (value.isObject()) { if (isJSArray(value)) { auto inspectorArray = JSON::Array::create(); @@ -163,7 +170,7 @@ Ref InjectedScriptBase::makeCall(ScriptFunctionCall& function) auto resultJSONValue = toInspectorValue(globalObject, value); if (!resultJSONValue) - return JSON::Value::create(makeString("Object has too long reference chain (must not be longer than "_s, JSON::Value::maxDepth, ')')); + return JSON::Value::create(String("Object couldn't be returned by value"_s)); return resultJSONValue.releaseNonNull(); } @@ -193,7 +200,7 @@ void InjectedScriptBase::makeAsyncCall(ScriptFunctionCall& function, AsyncCallCa else if (auto resultJSONValue = toInspectorValue(globalObject, callFrame->argument(0))) checkAsyncCallResult(resultJSONValue, callback); else - checkAsyncCallResult(JSON::Value::create(makeString("Object has too long reference chain (must not be longer than "_s, JSON::Value::maxDepth, ')')), callback); + checkAsyncCallResult(JSON::Value::create(String("Object couldn't be returned by value"_s)), callback); return JSC::JSValue::encode(JSC::jsUndefined()); }); }