diff --git a/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp b/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp index 3b136c4d98b5b..3a3ce33a4981e 100644 --- a/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp +++ b/Source/JavaScriptCore/inspector/ScriptCallStackFactory.cpp @@ -42,6 +42,7 @@ #include "ScriptArguments.h" #include "ScriptCallFrame.h" #include "ScriptExecutable.h" +#include #include namespace Inspector { @@ -168,11 +169,10 @@ static bool extractSourceInformationFromException(JSC::JSGlobalObject* globalObj return result; } -Ref createScriptCallStackFromException(JSC::JSGlobalObject* globalObject, JSC::Exception* exception, size_t maxStackSize) +Ref createScriptCallStackFromStackTrace(JSC::JSGlobalObject* globalObject, std::span stackTrace, JSC::JSValue value, size_t maxStackSize) { + auto& vm = globalObject->vm(); Vector frames; - auto& stackTrace = exception->stack(); - VM& vm = globalObject->vm(); for (size_t i = 0; i < stackTrace.size() && i < maxStackSize; i++) { auto lineColumn = stackTrace[i].computeLineAndColumn(); String functionName = stackTrace[i].functionName(vm); @@ -180,8 +180,8 @@ Ref createScriptCallStackFromException(JSC::JSGlobalObject* glo } // Fallback to getting at least the line and sourceURL from the exception object if it has values and the exceptionStack doesn't. - if (exception->value().isObject()) { - JSObject* exceptionObject = exception->value().toObject(globalObject); + if (value.isObject()) { + JSObject* exceptionObject = value.toObject(globalObject); ASSERT(exceptionObject); LineColumn lineColumn; String exceptionSourceURL; @@ -210,6 +210,12 @@ Ref createScriptCallStackFromException(JSC::JSGlobalObject* glo return ScriptCallStack::create(WTFMove(frames), stackTrace.size() > maxStackSize, parentStackTrace); } +Ref createScriptCallStackFromException(JSC::JSGlobalObject* globalObject, JSC::Exception* exception, size_t maxStackSize) +{ + const auto stackTrace = exception->stack(); + return createScriptCallStackFromStackTrace(globalObject, { stackTrace.begin(), stackTrace.end() }, exception->value(), maxStackSize); +} + Ref createScriptArguments(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame, unsigned skipArgumentCount) { VM& vm = globalObject->vm(); diff --git a/Source/JavaScriptCore/inspector/ScriptCallStackFactory.h b/Source/JavaScriptCore/inspector/ScriptCallStackFactory.h index 42577b5643172..932719cb5553b 100644 --- a/Source/JavaScriptCore/inspector/ScriptCallStackFactory.h +++ b/Source/JavaScriptCore/inspector/ScriptCallStackFactory.h @@ -49,6 +49,7 @@ class ScriptArguments; JS_EXPORT_PRIVATE Ref createScriptCallStack(JSC::JSGlobalObject*, size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture); JS_EXPORT_PRIVATE Ref createScriptCallStackForConsole(JSC::JSGlobalObject*, size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture); JS_EXPORT_PRIVATE Ref createScriptCallStackFromException(JSC::JSGlobalObject*, JSC::Exception*, size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture); +JS_EXPORT_PRIVATE Ref createScriptCallStackFromStackTrace(JSC::JSGlobalObject*, std::span, JSC::JSValue value, size_t maxStackSize = ScriptCallStack::maxCallStackSizeToCapture); JS_EXPORT_PRIVATE Ref createScriptArguments(JSC::JSGlobalObject*, JSC::CallFrame*, unsigned skipArgumentCount); } // namespace Inspector diff --git a/Source/JavaScriptCore/inspector/protocol/LifecycleReporter.json b/Source/JavaScriptCore/inspector/protocol/LifecycleReporter.json index 283e2c79c820f..20b45ec7d3da7 100644 --- a/Source/JavaScriptCore/inspector/protocol/LifecycleReporter.json +++ b/Source/JavaScriptCore/inspector/protocol/LifecycleReporter.json @@ -29,7 +29,13 @@ }, { "name": "error", - "parameters": [{ "name": "message", "$ref": "Console.ConsoleMessage", "description": "Source of the error" }] + "parameters": [ + { "name": "message", "type": "string", "description": "string associated with the error" }, + { "name": "name", "type": "string", "description": "If an Error instance, the error.name property" }, + { "name": "urls", "type": "array", "description": "Array of URLs associated with the error", "items": { "type": "string" } }, + { "name": "lineColumns", "type": "array", "description": "Line, column pairs associated with the error. Already sourcemapped.", "items": { "type": "integer" } }, + { "name": "sourceLines", "type": "array", "description": "Source code preview associated with the error for up to 5 lines before the error, relative to the first non-internal stack frame.", "items": { "type": "string" } } + ] } ] } diff --git a/Source/JavaScriptCore/inspector/protocol/TestReporter.json b/Source/JavaScriptCore/inspector/protocol/TestReporter.json index ef6644f55a36f..38bb3d9e91691 100644 --- a/Source/JavaScriptCore/inspector/protocol/TestReporter.json +++ b/Source/JavaScriptCore/inspector/protocol/TestReporter.json @@ -1,6 +1,6 @@ { "domain": "TestReporter", - "description": "TestReporter domain allows reporting of lifecycle events.", + "description": "TestReporter domain allows reporting of test-related events.", "debuggableTypes": ["itml", "javascript"], "targetTypes": ["itml", "javascript"], "types": [ @@ -28,7 +28,14 @@ { "name": "scriptId", "$ref": "Debugger.ScriptId", - "description": "Unique identifier of the script that started the test." + "description": "Unique identifier of the script the test is in. Available when the debugger is attached.", + "optional": true + }, + { + "name": "url", + "type": "string", + "description": "url of the script the test is in. Available when the debugger is not attached.", + "optional": true }, { "name": "line", @@ -49,7 +56,7 @@ { "name": "status", "$ref": "TestStatus", "description": "Status of the test that ended." }, { "name": "elapsed", - "type": "number", + "type": "integer", "description": "Elapsed time in milliseconds since the test started." } ]