From e7dbe91374429b0ebc8c7d0b0cf3d1ce4e75c3e4 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Mon, 13 Nov 2023 20:06:07 +0200 Subject: [PATCH] refactor: clean up protocol.json --- src/assets/protocol.json | 1359 +++-------------- .../jscript/engine/debug/SimpleDebugger.java | 7 +- 2 files changed, 182 insertions(+), 1184 deletions(-) diff --git a/src/assets/protocol.json b/src/assets/protocol.json index 246e736..4e5dcfe 100644 --- a/src/assets/protocol.json +++ b/src/assets/protocol.json @@ -56,7 +56,7 @@ "properties": [ { "name": "scriptId", "description": "Script identifier as reported in the `Debugger.scriptParsed`.", - "$ref": "Runtime.ScriptId" + "$ref": "Runtime.ID" }, { "name": "lineNumber", "description": "Line number in the script (0-based).", @@ -108,57 +108,21 @@ "description": "Disables debugging. This will have some performance benefit." }, - { "name": "continueToLocation", - "description": "Sets a one-off breakpoint to the specified location, and continues exectuion.", + { "name": "pause", + "description": "Stops on the next JavaScript statement." + }, + { "name": "resume", + "description": "Resumes JavaScript execution.", "parameters": [ - { "name": "location", - "description": "Location to continue to.", - "$ref": "Location" - } - ] - }, - { "name": "evaluateOnCallFrame", - "description": "Evaluates expression on a given call frame, without triggering any breakpoints. The expression should be pure.", - "parameters": [ - { "name": "callFrameId", - "description": "Call frame to evaluate on.", - "$ref": "CallFrameId" - }, - { "name": "expression", - "description": "Expression to evaluate.", - "type": "string" - }, - { "name": "silent", - "description": "Ignores any exceptions that may occur during evaluation. Overrides `setPauseOnException` state.", - "optional": true, - "type": "boolean" - }, - { "name": "returnByValue", - "description": "Whether the result is expected to be a JSON object that should be sent by value.", - "deprecated": true, - "optional": true, - "type": "boolean" - }, - { "name": "timeout", - "description": "Terminate execution after timing out (number of milliseconds).", - "optional": true, - "type": "number" - } - ], - "returns": [ - { - "name": "result", - "description": "Object wrapper for the evaluation result.", - "$ref": "Runtime.RemoteObject" - }, - { - "name": "exceptionDetails", - "description": "Exception details.", - "optional": true, - "$ref": "Runtime.ExceptionDetails" + { + "name": "terminateOnResume", + "description": "Set to true to terminate execution upon resuming execution. In contrast\nto Runtime.terminateExecution, this will allows to execute further\nJavaScript (i.e. via evaluation) until execution of the paused code\nis actually resumed, at which point termination is triggered.\nIf execution is currently not paused, this parameter has no effect.", + "optional": true, + "type": "boolean" } ] }, + { "name": "getPossibleBreakpoints", "description": "Returns possible locations for breakpoint. scriptId in start and end range locations should be\nthe same.", "parameters": [ @@ -197,7 +161,7 @@ { "name": "scriptId", "description": "Id of the script to get source for.", - "$ref": "Runtime.ScriptId" + "$ref": "Runtime.ID" } ], "returns": [ @@ -214,24 +178,6 @@ } ] }, - { "name": "getWasmBytecode", - "description": "This command is deprecated. Use getScriptSource instead.", - "deprecated": true, - "parameters": [ - { - "name": "scriptId", - "description": "Id of the Wasm script to get source for.", - "$ref": "Runtime.ScriptId" - } - ], - "returns": [ - { - "name": "bytecode", - "description": "Script source.", - "type": "binary" - } - ] - }, { "name": "getStackTrace", "description": "Returns stack trace with given `stackTraceId`.", "experimental": true, @@ -248,202 +194,7 @@ } ] }, - { "name": "pause", - "description": "Stops on the next JavaScript statement." - }, - { "name": "pauseOnAsyncCall", - "experimental": true, - "deprecated": true, - "parameters": [ - { - "name": "parentStackTraceId", - "description": "Debugger will pause when async call with given stack trace is started.", - "$ref": "Runtime.StackTraceId" - } - ] - }, - { "name": "removeBreakpoint", - "description": "Removes JavaScript breakpoint.", - "parameters": [ - { - "name": "breakpointId", - "$ref": "BreakpointId" - } - ] - }, - { "name": "restartFrame", - "description": "Restarts particular call frame from the beginning.", - "deprecated": true, - "parameters": [ - { - "name": "callFrameId", - "description": "Call frame identifier to evaluate on.", - "$ref": "CallFrameId" - } - ], - "returns": [ - { - "name": "callFrames", - "description": "New stack trace.", - "type": "array", - "items": { - "$ref": "CallFrame" - } - }, - { - "name": "asyncStackTrace", - "description": "Async stack trace, if any.", - "optional": true, - "$ref": "Runtime.StackTrace" - }, - { - "name": "asyncStackTraceId", - "description": "Async stack trace, if any.", - "experimental": true, - "optional": true, - "$ref": "Runtime.StackTraceId" - } - ] - }, - { "name": "resume", - "description": "Resumes JavaScript execution.", - "parameters": [ - { - "name": "terminateOnResume", - "description": "Set to true to terminate execution upon resuming execution. In contrast\nto Runtime.terminateExecution, this will allows to execute further\nJavaScript (i.e. via evaluation) until execution of the paused code\nis actually resumed, at which point termination is triggered.\nIf execution is currently not paused, this parameter has no effect.", - "optional": true, - "type": "boolean" - } - ] - }, - { "name": "searchInContent", - "description": "Searches for given string in script content.", - "parameters": [ - { - "name": "scriptId", - "description": "Id of the script to search in.", - "$ref": "Runtime.ScriptId" - }, - { - "name": "query", - "description": "String to search for.", - "type": "string" - }, - { - "name": "caseSensitive", - "description": "If true, search is case sensitive.", - "optional": true, - "type": "boolean" - }, - { - "name": "isRegex", - "description": "If true, treats string parameter as regex.", - "optional": true, - "type": "boolean" - } - ], - "returns": [ - { - "name": "result", - "description": "List of search matches.", - "type": "array", - "items": { - "$ref": "SearchMatch" - } - } - ] - }, - { "name": "setAsyncCallStackDepth", - "description": "Enables or disables async call stacks tracking.", - "parameters": [ - { - "name": "maxDepth", - "description": "Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async\ncall stacks (default).", - "type": "integer" - } - ] - }, - { "name": "setBlackboxPatterns", - "description": "Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in\nscripts with url matching one of the patterns. VM will try to leave blackboxed script by\nperforming 'step in' several times, finally resorting to 'step out' if unsuccessful.", - "experimental": true, - "parameters": [ - { - "name": "patterns", - "description": "Array of regexps that will be used to check script url for blackbox state.", - "type": "array", - "items": { - "type": "string" - } - } - ] - }, - { "name": "setBlackboxedRanges", - "description": "Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted\nscripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful.\nPositions array contains positions where blackbox state is changed. First interval isn't\nblackboxed. Array should be sorted.", - "experimental": true, - "parameters": [ - { - "name": "scriptId", - "description": "Id of the script.", - "$ref": "Runtime.ScriptId" - }, - { - "name": "positions", - "type": "array", - "items": { - "$ref": "ScriptPosition" - } - } - ] - }, - { "name": "setBreakpoint", - "description": "Sets JavaScript breakpoint at a given location.", - "parameters": [ - { - "name": "location", - "description": "Location to set breakpoint in.", - "$ref": "Location" - }, - { - "name": "condition", - "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the\nbreakpoint if this expression evaluates to true.", - "optional": true, - "type": "string" - } - ], - "returns": [ - { - "name": "breakpointId", - "description": "Id of the created breakpoint for further reference.", - "$ref": "BreakpointId" - }, - { - "name": "actualLocation", - "description": "Location this breakpoint resolved into.", - "$ref": "Location" - } - ] - }, - { "name": "setInstrumentationBreakpoint", - "description": "Sets instrumentation breakpoint.", - "parameters": [ - { - "name": "instrumentation", - "description": "Instrumentation name.", - "type": "string", - "enum": [ - "beforeScriptExecution", - "beforeScriptWithSourceMapExecution" - ] - } - ], - "returns": [ - { - "name": "breakpointId", - "description": "Id of the created breakpoint for further reference.", - "$ref": "BreakpointId" - } - ] - }, + { "name": "setBreakpointByUrl", "description": "Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this\ncommand is issued, all existing parsed scripts will have breakpoints resolved and returned in\n`locations` property. Further matching script parsing will result in subsequent\n`breakpointResolved` events issued. This logical breakpoint will survive page reloads.", "parameters": [ @@ -499,18 +250,17 @@ } ] }, - { "name": "setBreakpointOnFunctionCall", - "description": "Sets JavaScript breakpoint before each call to the given function.\nIf another function was created from the same source as a given one,\ncalling it will also trigger the breakpoint.", - "experimental": true, + { "name": "setBreakpoint", + "description": "Sets JavaScript breakpoint at a given location.", "parameters": [ { - "name": "objectId", - "description": "Function object id.", - "$ref": "Runtime.RemoteObjectId" + "name": "location", + "description": "Location to set breakpoint in.", + "$ref": "Location" }, { "name": "condition", - "description": "Expression to use as a breakpoint condition. When specified, debugger will\nstop on the breakpoint if this expression evaluates to true.", + "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the\nbreakpoint if this expression evaluates to true.", "optional": true, "type": "string" } @@ -520,9 +270,36 @@ "name": "breakpointId", "description": "Id of the created breakpoint for further reference.", "$ref": "BreakpointId" + }, + { + "name": "actualLocation", + "description": "Location this breakpoint resolved into.", + "$ref": "Location" } ] }, + { "name": "setInstrumentationBreakpoint", + "description": "Sets instrumentation breakpoint.", + "parameters": [ + { + "name": "instrumentation", + "description": "Instrumentation name.", + "type": "string", + "enum": [ + "beforeScriptExecution", + "beforeScriptWithSourceMapExecution" + ] + } + ], + "returns": [ + { + "name": "breakpointId", + "description": "Id of the created breakpoint for further reference.", + "$ref": "BreakpointId" + } + ], + "todo": "// TODO: implement!!" + }, { "name": "setBreakpointsActive", "description": "Activates / deactivates all breakpoints on the page.", "parameters": [ @@ -543,114 +320,74 @@ "enum": [ "none", "uncaught", - "all" + "all" ] } ] }, - { "name": "setReturnValue", - "description": "Changes return value in top frame. Available only at return break position.", - "experimental": true, + + { "name": "continueToLocation", + "description": "Sets a one-off breakpoint to the specified location, and continues exectuion.", "parameters": [ - { - "name": "newValue", - "description": "New return value.", - "$ref": "Runtime.CallArgument" + { "name": "location", + "description": "Location to continue to.", + "$ref": "Location" } ] }, - { "name": "setScriptSource", - "description": "Edits JavaScript source live.", + { "name": "removeBreakpoint", + "description": "Removes JavaScript breakpoint.", "parameters": [ { - "name": "scriptId", - "description": "Id of the script to edit.", - "$ref": "Runtime.ScriptId" + "name": "breakpointId", + "$ref": "BreakpointId" + } + ] + }, + + { "name": "evaluateOnCallFrame", + "description": "Evaluates expression on a given call frame, without triggering any breakpoints. The expression should be pure.", + "parameters": [ + { "name": "callFrameId", + "description": "Call frame to evaluate on.", + "$ref": "CallFrameId" }, - { - "name": "scriptSource", - "description": "New content of the script.", + { "name": "expression", + "description": "Expression to evaluate.", "type": "string" }, - { - "name": "dryRun", - "description": "If true the change will not actually be applied. Dry run may be used to get result\ndescription without actually modifying the code.", + { "name": "silent", + "description": "Ignores any exceptions that may occur during evaluation. Overrides `setPauseOnException` state.", "optional": true, "type": "boolean" + }, + { "name": "returnByValue", + "description": "Whether the result is expected to be a JSON object that should be sent by value.", + "deprecated": true, + "optional": true, + "type": "boolean" + }, + { "name": "timeout", + "description": "Terminate execution after timing out (number of milliseconds).", + "optional": true, + "type": "number" } ], "returns": [ { - "name": "callFrames", - "description": "New stack trace in case editing has happened while VM was stopped.", - "optional": true, - "type": "array", - "items": { - "$ref": "CallFrame" - } - }, - { - "name": "stackChanged", - "description": "Whether current call stack was modified after applying the changes.", - "optional": true, - "type": "boolean" - }, - { - "name": "asyncStackTrace", - "description": "Async stack trace, if any.", - "optional": true, - "$ref": "Runtime.StackTrace" - }, - { - "name": "asyncStackTraceId", - "description": "Async stack trace, if any.", - "experimental": true, - "optional": true, - "$ref": "Runtime.StackTraceId" + "name": "result", + "description": "Object wrapper for the evaluation result.", + "$ref": "Runtime.RemoteObject" }, { "name": "exceptionDetails", - "description": "Exception details if any.", + "description": "Exception details.", "optional": true, "$ref": "Runtime.ExceptionDetails" } ] }, - { "name": "setSkipAllPauses", - "description": "Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).", - "parameters": [ - { - "name": "skip", - "description": "New value for skip pauses state.", - "type": "boolean" - } - ] - }, - { "name": "setVariableValue", - "description": "Changes value of variable in a callframe. Object-based scopes are not supported and must be\nmutated manually.", - "parameters": [ - { - "name": "scopeNumber", - "description": "0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch'\nscope types are allowed. Other scopes could be manipulated manually.", - "type": "integer" - }, - { - "name": "variableName", - "description": "Variable name.", - "type": "string" - }, - { - "name": "newValue", - "description": "New variable value.", - "$ref": "Runtime.CallArgument" - }, - { - "name": "callFrameId", - "description": "Id of callframe that holds variable.", - "$ref": "CallFrameId" - } - ] - }, + { "name": "stepInto", "description": "Steps into the function call." }, @@ -754,7 +491,7 @@ { "name": "scriptId", "description": "Identifier of the script parsed.", - "$ref": "Runtime.ScriptId" + "$ref": "Runtime.ID" }, { "name": "url", @@ -852,7 +589,7 @@ { "name": "scriptId", "description": "Identifier of the script parsed.", - "$ref": "Runtime.ScriptId" + "$ref": "Runtime.ID" }, { "name": "url", @@ -963,32 +700,29 @@ { "domain": "Runtime", "types": [ - { "id": "ScriptId", - "description": "Unique script identifier.", + { "id": "ID", + "description": "The string representation of an integer ID. All identifiable constructs share the same ID repository.", "type": "string" }, - { "id": "RemoteObjectId", - "description": "Unique object identifier.", - "type": "string" - }, - { "id": "Timestamp", "description": "Number of milliseconds since epoch.", "type": "number" }, - { "id": "TimeDelta", - "description": "Number of milliseconds.", - "type": "number" - }, + { "id": "UnserializableValue", - "description": "Primitive value which cannot be JSON-stringified. Includes values `-0`, `NaN`, `Infinity`,\n`-Infinity`, and bigint literals.", + "description": "The string representation of a value that can't be JSON serialized.", "type": "string" }, { "id": "RemoteObject", "description": "Mirror object referencing original JavaScript object.", "type": "object", "properties": [ + { "name": "objectId", + "description": "Unique object identifier (for non-primitive values).", + "optional": true, + "$ref": "ID" + }, { "name": "type", "description": "Object type.", "type": "string", @@ -1008,13 +742,7 @@ "type": "string", "enum": [ "array", - "null", - "regexp", - "date", - "map", - "set", - "generator", - "promise" + "null" ] }, { "name": "className", @@ -1023,12 +751,12 @@ "type": "string" }, { "name": "value", - "description": "Remote object value in case of primitive values or JSON values (if it was requested).", + "description": "Remote object value in case of primitive values.", "optional": true, "type": "any" }, { "name": "unserializableValue", - "description": "Primitive value which can not be JSON-stringified does not have `value`, but gets this\nproperty.", + "description": "In case of a non JSON-serializable value, its string representation is provided here.", "optional": true, "$ref": "UnserializableValue" }, @@ -1036,85 +764,6 @@ "description": "String representation of the object.", "optional": true, "type": "string" - }, - { "name": "objectId", - "description": "Unique object identifier (for non-primitive values).", - "optional": true, - "$ref": "RemoteObjectId" - } - ] - }, - { "id": "MemberDescriptor", - "description": "Object member descriptor, mirroring the object descriptor in JavaScript (https://developer.mozilla.org/en-US/docs/Glossary/Property/JavaScript).", - "type": "object", - "properties": [ - { "name": "name", - "description": "String representation of the member name.", - "type": "string" - }, - { "name": "value", - "description": "The value of the member, if it's a field.", - "optional": true, - "$ref": "RemoteObject" - }, - { "name": "writable", - "description": "Whether or not the member is writable. Present only if the member is a field.", - "optional": true, - "type": "boolean" - }, - { "name": "configurable", - "description": "Whether or not the member is configurable.", - "type": "boolean" - }, - { "name": "enumerable", - "description": "Whether or not the member is enumerable..", - "type": "boolean" - }, - { "name": "get", - "description": "The getter of the member. Present only if the member is a property and the property has a getter.", - "optional": true, - "$ref": "RemoteObject" - }, - { "name": "set", - "description": "The setter of the member. Present only if the member is a property and the property has a setter.", - "optional": true, - "$ref": "RemoteObject" - }, - { "name": "wasThrown", - "description": "True if the member's value was thrown during the evaluation of the getter.", - "optional": true, - "type": "boolean" - }, - { "name": "isOwn", - "description": "True if the property is owned for the object.", - "optional": true, - "type": "boolean" - }, - { "name": "symbol", - "description": "If the member name is a symbol, this will be the reference of the symbol.", - "optional": true, - "$ref": "RemoteObject" - } - ] - }, - { "id": "CallArgument", - "description": "Represents function call argument. Only one of the three optional fields should be specified, or none for undefined.", - "type": "object", - "properties": [ - { "name": "value", - "description": "Primitive value or serializable javascript object.", - "optional": true, - "type": "any" - }, - { "name": "unserializableValue", - "description": "Primitive value which can not be JSON-stringified.", - "optional": true, - "$ref": "UnserializableValue" - }, - { "name": "objectId", - "description": "Remote object handle.", - "optional": true, - "$ref": "RemoteObjectId" } ] }, @@ -1142,7 +791,7 @@ }, { "name": "scriptId", "description": "Script ID of the exception location.", - "$ref": "ScriptId" + "$ref": "ID" }, { "name": "lineNumber", "description": "Line number of the exception location (0-based).", @@ -1164,7 +813,7 @@ }, { "name": "scriptId", "description": "JavaScript script id.", - "$ref": "ScriptId" + "$ref": "ID" }, { "name": "lineNumber", "description": "JavaScript script line number (0-based).", @@ -1191,637 +840,106 @@ "items": { "$ref": "CallFrame" } } ] + }, + + { "id": "MemberDescriptor", + "description": "An object, representing a property of another object.", + "type": "object", + "properties": [ + { "name": "name", + "description": "The name of the property. Although the property's key might not be a string,\nthe key is always converted to a string.", + "type": "string" + }, + + { "name": "writable", + "description": "The writable flag of the property. Present only if the member is a field.", + "type": "boolean", + "optional": true + }, + { "name": "enumerable", + "description": "The enumerable flag of the property.", + "type": "boolean", + "optional": true + }, + { "name": "configurable", + "description": "The configurable flag of the property.", + "type": "boolean", + "optional": true + }, + { "name": "isOwn", + "description": "Always true.", + "type": "boolean" + }, + + { "name": "get", + "description": "The remote function that is the getter of the property.\nNot present if the member is not a property or it doesn't have a getter.", + "$ref": "RemoteObject", + "optional": true + }, + { "name": "set", + "description": "The remote function that is the setter of the property.\nNot present if the member is not a property or it doesn't have a setter.", + "$ref": "RemoteObject", + "optional": true + }, + { "name": "value", + "description": "The remote value of the field. Present only if the member is a field.", + "$ref": "RemoteObject", + "optional": true + } + ] } ], "commands": [ - { "name": "awaitPromise", - "description": "Add handler to promise with given promise object id.", + { "name": "enable", + "description": "Enables reporting of execution contexts creation by means of `executionContextCreated` event.\nWhen the reporting gets enabled the event will be sent immediately for each existing execution\ncontext." + }, + { "name": "getProperties", + "description": "Returns a list of all owned members of the specified object.", "parameters": [ - { "name": "promiseObjectId", - "description": "Identifier of the promise.", - "$ref": "RemoteObjectId" - }, - { "name": "returnByValue", - "description": "Whether the result is expected to be a JSON object that should be sent by value.", - "optional": true, - "type": "boolean" + { "name": "objectId", + "description": "Identifier of the object to return properties for.", + "$ref": "ID" } ], "returns": [ { "name": "result", - "description": "Promise result. Will contain rejected value if promise was rejected.", - "$ref": "RemoteObject" - }, - { "name": "exceptionDetails", - "description": "Exception details if stack strace is available.", - "optional": true, - "$ref": "ExceptionDetails" - } - ] - }, - { "name": "callFunctionOn", - "description": "Calls function with given declaration on the given object.", - "parameters": [ - { "name": "functionDeclaration", - "description": "Declaration of the function to call.", - "type": "string" - }, - { "name": "objectId", - "description": "Identifier of the object to call function on. Either objectId or executionContextId should be specified.", - "optional": true, - "$ref": "RemoteObjectId" - }, - { "name": "arguments", - "description": "Call arguments. All call arguments must belong to the same JavaScript world as the target\nobject.", - "optional": true, - "type": "array", - "items": { - "$ref": "CallArgument" - } - }, - { "name": "silent", - "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause\nexecution. Overrides `setPauseOnException` state.", - "optional": true, - "type": "boolean" - }, - { "name": "returnByValue", - "description": "Whether the result is expected to be a JSON object which should be sent by value.", - "optional": true, - "type": "boolean" - }, - { "name": "awaitPromise", - "description": "Whether execution should `await` for resulting value and return once awaited promise is\nresolved.", - "optional": true, - "type": "boolean" - }, - { - "name": "objectGroup", - "description": "Symbolic group name that can be used to release multiple objects. If objectGroup is not\nspecified and objectId is, objectGroup will be inherited from object.", - "optional": true, - "type": "string" - }, - { - "name": "throwOnSideEffect", - "description": "Whether to throw an exception if side effect cannot be ruled out during evaluation.", - "experimental": true, - "optional": true, - "type": "boolean" - }, - { - "name": "generateWebDriverValue", - "description": "Whether the result should be serialized according to https://w3c.github.io/webdriver-bidi.", - "experimental": true, - "optional": true, - "type": "boolean" - } - ], - "returns": [ - { - "name": "result", - "description": "Call result.", - "$ref": "RemoteObject" - }, - { - "name": "exceptionDetails", - "description": "Exception details.", - "optional": true, - "$ref": "ExceptionDetails" - } - ] - }, - { - "name": "compileScript", - "description": "Compiles expression.", - "parameters": [ - { - "name": "expression", - "description": "Expression to compile.", - "type": "string" - }, - { - "name": "sourceURL", - "description": "Source url to be set for the script.", - "type": "string" - }, - { - "name": "persistScript", - "description": "Specifies whether the compiled script should be persisted.", - "type": "boolean" - }, - { - "name": "executionContextId", - "description": "Specifies in which execution context to perform script run. If the parameter is omitted the\nevaluation will be performed in the context of the inspected page.", - "optional": true, - "$ref": "ExecutionContextId" - } - ], - "returns": [ - { - "name": "scriptId", - "description": "Id of the script.", - "optional": true, - "$ref": "ScriptId" - }, - { - "name": "exceptionDetails", - "description": "Exception details.", - "optional": true, - "$ref": "ExceptionDetails" - } - ] - }, - { - "name": "disable", - "description": "Disables reporting of execution contexts creation." - }, - { - "name": "discardConsoleEntries", - "description": "Discards collected exceptions and console API calls." - }, - { - "name": "enable", - "description": "Enables reporting of execution contexts creation by means of `executionContextCreated` event.\nWhen the reporting gets enabled the event will be sent immediately for each existing execution\ncontext." - }, - { - "name": "evaluate", - "description": "Evaluates expression on global object.", - "parameters": [ - { - "name": "expression", - "description": "Expression to evaluate.", - "type": "string" - }, - { - "name": "objectGroup", - "description": "Symbolic group name that can be used to release multiple objects.", - "optional": true, - "type": "string" - }, - { - "name": "includeCommandLineAPI", - "description": "Determines whether Command Line API should be available during the evaluation.", - "optional": true, - "type": "boolean" - }, - { - "name": "silent", - "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause\nexecution. Overrides `setPauseOnException` state.", - "optional": true, - "type": "boolean" - }, - { - "name": "contextId", - "description": "Specifies in which execution context to perform evaluation. If the parameter is omitted the\nevaluation will be performed in the context of the inspected page.\nThis is mutually exclusive with `uniqueContextId`, which offers an\nalternative way to identify the execution context that is more reliable\nin a multi-process environment.", - "optional": true, - "$ref": "ExecutionContextId" - }, - { - "name": "returnByValue", - "description": "Whether the result is expected to be a JSON object that should be sent by value.", - "optional": true, - "type": "boolean" - }, - { - "name": "generatePreview", - "description": "Whether preview should be generated for the result.", - "experimental": true, - "optional": true, - "type": "boolean" - }, - { - "name": "userGesture", - "description": "Whether execution should be treated as initiated by user in the UI.", - "optional": true, - "type": "boolean" - }, - { - "name": "awaitPromise", - "description": "Whether execution should `await` for resulting value and return once awaited promise is\nresolved.", - "optional": true, - "type": "boolean" - }, - { - "name": "throwOnSideEffect", - "description": "Whether to throw an exception if side effect cannot be ruled out during evaluation.\nThis implies `disableBreaks` below.", - "experimental": true, - "optional": true, - "type": "boolean" - }, - { - "name": "timeout", - "description": "Terminate execution after timing out (number of milliseconds).", - "experimental": true, - "optional": true, - "$ref": "TimeDelta" - }, - { - "name": "disableBreaks", - "description": "Disable breakpoints during execution.", - "experimental": true, - "optional": true, - "type": "boolean" - }, - { - "name": "replMode", - "description": "Setting this flag to true enables `let` re-declaration and top-level `await`.\nNote that `let` variables can only be re-declared if they originate from\n`replMode` themselves.", - "experimental": true, - "optional": true, - "type": "boolean" - }, - { - "name": "allowUnsafeEvalBlockedByCSP", - "description": "The Content Security Policy (CSP) for the target might block 'unsafe-eval'\nwhich includes eval(), Function(), setTimeout() and setInterval()\nwhen called with non-callable arguments. This flag bypasses CSP for this\nevaluation and allows unsafe-eval. Defaults to true.", - "experimental": true, - "optional": true, - "type": "boolean" - }, - { - "name": "uniqueContextId", - "description": "An alternative way to specify the execution context to evaluate in.\nCompared to contextId that may be reused across processes, this is guaranteed to be\nsystem-unique, so it can be used to prevent accidental evaluation of the expression\nin context different than intended (e.g. as a result of navigation across process\nboundaries).\nThis is mutually exclusive with `contextId`.", - "experimental": true, - "optional": true, - "type": "string" - }, - { - "name": "generateWebDriverValue", - "description": "Whether the result should be serialized according to https://w3c.github.io/webdriver-bidi.", - "experimental": true, - "optional": true, - "type": "boolean" - } - ], - "returns": [ - { - "name": "result", - "description": "Evaluation result.", - "$ref": "RemoteObject" - }, - { - "name": "exceptionDetails", - "description": "Exception details.", - "optional": true, - "$ref": "ExceptionDetails" - } - ] - }, - { - "name": "getIsolateId", - "description": "Returns the isolate id.", - "experimental": true, - "returns": [ - { - "name": "id", - "description": "The isolate id.", - "type": "string" - } - ] - }, - { - "name": "getHeapUsage", - "description": "Returns the JavaScript heap usage.\nIt is the total usage of the corresponding isolate not scoped to a particular Runtime.", - "experimental": true, - "returns": [ - { - "name": "usedSize", - "description": "Used heap size in bytes.", - "type": "number" - }, - { - "name": "totalSize", - "description": "Allocated heap size in bytes.", - "type": "number" - } - ] - }, - { - "name": "getProperties", - "description": "Returns properties of a given object. Object group of the result is inherited from the target\nobject.", - "parameters": [ - { - "name": "objectId", - "description": "Identifier of the object to return properties for.", - "$ref": "RemoteObjectId" - }, - { - "name": "ownProperties", - "description": "If true, returns properties belonging only to the element itself, not to its prototype\nchain.", - "optional": true, - "type": "boolean" - }, - { - "name": "accessorPropertiesOnly", - "description": "If true, returns accessor properties (with getter/setter) only; internal properties are not\nreturned either.", - "experimental": true, - "optional": true, - "type": "boolean" - }, - { - "name": "generatePreview", - "description": "Whether preview should be generated for the results.", - "experimental": true, - "optional": true, - "type": "boolean" - }, - { - "name": "nonIndexedPropertiesOnly", - "description": "If true, returns non-indexed properties only.", - "experimental": true, - "optional": true, - "type": "boolean" - } - ], - "returns": [ - { - "name": "result", "description": "Object properties.", "type": "array", "items": { - "$ref": "PropertyDescriptor" - } - }, - { - "name": "internalProperties", - "description": "Internal object properties (only of the element itself).", - "optional": true, - "type": "array", - "items": { - "$ref": "InternalPropertyDescriptor" - } - }, - { - "name": "privateProperties", - "description": "Object private properties.", - "experimental": true, - "optional": true, - "type": "array", - "items": { - "$ref": "PrivatePropertyDescriptor" - } - }, - { - "name": "exceptionDetails", - "description": "Exception details.", - "optional": true, - "$ref": "ExceptionDetails" - } - ] - }, - { - "name": "globalLexicalScopeNames", - "description": "Returns all let, const and class variables from global scope.", - "parameters": [ - { - "name": "executionContextId", - "description": "Specifies in which execution context to lookup global scope variables.", - "optional": true, - "$ref": "ExecutionContextId" - } - ], - "returns": [ - { - "name": "names", - "type": "array", - "items": { - "type": "string" + "$ref": "MemberDescriptor" } } ] }, - { - "name": "queryObjects", - "parameters": [ - { - "name": "prototypeObjectId", - "description": "Identifier of the prototype to return objects for.", - "$ref": "RemoteObjectId" - }, - { - "name": "objectGroup", - "description": "Symbolic group name that can be used to release the results.", - "optional": true, - "type": "string" - } - ], - "returns": [ - { - "name": "objects", - "description": "Array with objects.", - "$ref": "RemoteObject" - } - ] - }, - { - "name": "releaseObject", + { "name": "releaseObject", "description": "Releases remote object with given id.", "parameters": [ - { - "name": "objectId", + { "name": "objectId", "description": "Identifier of the object to release.", - "$ref": "RemoteObjectId" + "$ref": "ID" } ] }, - { - "name": "releaseObjectGroup", + { "name": "releaseObjectGroup", "description": "Releases all remote objects that belong to a given group.", "parameters": [ - { - "name": "objectGroup", + { "name": "objectGroup", "description": "Symbolic object group name.", "type": "string" } ] }, - { - "name": "runIfWaitingForDebugger", - "description": "Tells inspected instance to run if it was waiting for debugger to attach." - }, - { - "name": "runScript", - "description": "Runs script with given id in a given context.", - "parameters": [ - { - "name": "scriptId", - "description": "Id of the script to run.", - "$ref": "ScriptId" - }, - { - "name": "executionContextId", - "description": "Specifies in which execution context to perform script run. If the parameter is omitted the\nevaluation will be performed in the context of the inspected page.", - "optional": true, - "$ref": "ExecutionContextId" - }, - { - "name": "objectGroup", - "description": "Symbolic group name that can be used to release multiple objects.", - "optional": true, - "type": "string" - }, - { - "name": "silent", - "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause\nexecution. Overrides `setPauseOnException` state.", - "optional": true, - "type": "boolean" - }, - { - "name": "includeCommandLineAPI", - "description": "Determines whether Command Line API should be available during the evaluation.", - "optional": true, - "type": "boolean" - }, - { - "name": "returnByValue", - "description": "Whether the result is expected to be a JSON object which should be sent by value.", - "optional": true, - "type": "boolean" - }, - { - "name": "generatePreview", - "description": "Whether preview should be generated for the result.", - "optional": true, - "type": "boolean" - }, - { - "name": "awaitPromise", - "description": "Whether execution should `await` for resulting value and return once awaited promise is\nresolved.", - "optional": true, - "type": "boolean" - } - ], - "returns": [ - { - "name": "result", - "description": "Run result.", - "$ref": "RemoteObject" - }, - { - "name": "exceptionDetails", - "description": "Exception details.", - "optional": true, - "$ref": "ExceptionDetails" - } - ] - }, - { - "name": "setAsyncCallStackDepth", - "description": "Enables or disables async call stacks tracking.", - "redirect": "Debugger", - "parameters": [ - { - "name": "maxDepth", - "description": "Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async\ncall stacks (default).", - "type": "integer" - } - ] - }, - { - "name": "setCustomObjectFormatterEnabled", - "experimental": true, - "parameters": [ - { - "name": "enabled", - "type": "boolean" - } - ] - }, - { - "name": "setMaxCallStackSizeToCapture", - "experimental": true, - "parameters": [ - { - "name": "size", - "type": "integer" - } - ] - }, - { - "name": "terminateExecution", - "description": "Terminate current or next JavaScript execution.\nWill cancel the termination when the outer-most script execution ends.", - "experimental": true - }, - { - "name": "addBinding", - "description": "If executionContextId is empty, adds binding with the given name on the\nglobal objects of all inspected contexts, including those created later,\nbindings survive reloads.\nBinding function takes exactly one argument, this argument should be string,\nin case of any other input, function throws an exception.\nEach binding function call produces Runtime.bindingCalled notification.", - "experimental": true, - "parameters": [ - { - "name": "name", - "type": "string" - }, - { - "name": "executionContextId", - "description": "If specified, the binding would only be exposed to the specified\nexecution context. If omitted and `executionContextName` is not set,\nthe binding is exposed to all execution contexts of the target.\nThis parameter is mutually exclusive with `executionContextName`.\nDeprecated in favor of `executionContextName` due to an unclear use case\nand bugs in implementation (crbug.com/1169639). `executionContextId` will be\nremoved in the future.", - "deprecated": true, - "optional": true, - "$ref": "ExecutionContextId" - }, - { - "name": "executionContextName", - "description": "If specified, the binding is exposed to the executionContext with\nmatching name, even for contexts created after the binding is added.\nSee also `ExecutionContext.name` and `worldName` parameter to\n`Page.addScriptToEvaluateOnNewDocument`.\nThis parameter is mutually exclusive with `executionContextId`.", - "experimental": true, - "optional": true, - "type": "string" - } - ] - }, - { - "name": "removeBinding", - "description": "This method does not remove binding function from global object but\nunsubscribes current runtime agent from Runtime.bindingCalled notifications.", - "experimental": true, - "parameters": [ - { - "name": "name", - "type": "string" - } - ] - }, - { - "name": "getExceptionDetails", - "description": "This method tries to lookup and populate exception details for a\nJavaScript Error object.\nNote that the stackTrace portion of the resulting exceptionDetails will\nonly be populated if the Runtime domain was enabled at the time when the\nError was thrown.", - "experimental": true, - "parameters": [ - { - "name": "errorObjectId", - "description": "The error object for which to resolve the exception details.", - "$ref": "RemoteObjectId" - } - ], - "returns": [ - { - "name": "exceptionDetails", - "optional": true, - "$ref": "ExceptionDetails" - } - ] + { "name": "runIfWaitingForDebugger", + "description": "Tells inspected instance to run if it was waiting for debugger to attach.", + "todo": "// TODO: implement!!" } ], "events": [ - { - "name": "bindingCalled", - "description": "Notification is issued every time when binding is called.", - "experimental": true, - "parameters": [ - { - "name": "name", - "type": "string" - }, - { - "name": "payload", - "type": "string" - }, - { - "name": "executionContextId", - "description": "Identifier of the context where the call was made.", - "$ref": "ExecutionContextId" - } - ] - }, - { - "name": "consoleAPICalled", + { "name": "consoleAPICalled", + "todo":"// TODO: implement!!", "description": "Issued when console API was called.", "parameters": [ - { - "name": "type", + { "name": "type", "description": "Type of the call.", "type": "string", "enum": [ @@ -1845,57 +963,28 @@ "timeEnd" ] }, - { - "name": "args", + { "name": "args", "description": "Call arguments.", "type": "array", - "items": { - "$ref": "RemoteObject" - } + "items": { "$ref": "RemoteObject" } }, - { - "name": "executionContextId", + { "name": "executionContextId", "description": "Identifier of the context where the call was made.", "$ref": "ExecutionContextId" }, - { - "name": "timestamp", + { "name": "timestamp", "description": "Call timestamp.", "$ref": "Timestamp" }, - { - "name": "stackTrace", + { "name": "stackTrace", "description": "Stack trace captured when the call was made. The async stack chain is automatically reported for\nthe following call types: `assert`, `error`, `trace`, `warning`. For other types the async call\nchain can be retrieved using `Debugger.getStackTrace` and `stackTrace.parentId` field.", "optional": true, "$ref": "StackTrace" - }, - { - "name": "context", - "description": "Console context descriptor for calls on non-default console context (not console.*):\n'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call\non named context.", - "experimental": true, - "optional": true, - "type": "string" } ] }, - { - "name": "exceptionRevoked", - "description": "Issued when unhandled exception was revoked.", - "parameters": [ - { - "name": "reason", - "description": "Reason describing why exception was revoked.", - "type": "string" - }, - { - "name": "exceptionId", - "description": "The id of revoked exception, as reported in `exceptionThrown`.", - "type": "integer" - } - ] - }, - { - "name": "exceptionThrown", + { "name": "exceptionThrown", + "todo":"// TODO: implement!!", "description": "Issued when exception was thrown and unhandled.", "parameters": [ { @@ -1908,98 +997,6 @@ "$ref": "ExceptionDetails" } ] - }, - { - "name": "executionContextCreated", - "description": "Issued when new execution context is created.", - "parameters": [ - { - "name": "context", - "description": "A newly created execution context.", - "$ref": "ExecutionContextDescription" - } - ] - }, - { - "name": "executionContextDestroyed", - "description": "Issued when execution context is destroyed.", - "parameters": [ - { - "name": "executionContextId", - "description": "Id of the destroyed context", - "$ref": "ExecutionContextId" - } - ] - }, - { - "name": "executionContextsCleared", - "description": "Issued when all executionContexts were cleared in browser" - }, - { - "name": "inspectRequested", - "description": "Issued when object should be inspected (for example, as a result of inspect() command line API\ncall).", - "parameters": [ - { - "name": "object", - "$ref": "RemoteObject" - }, - { - "name": "hints", - "type": "object" - }, - { - "name": "executionContextId", - "description": "Identifier of the context where the call was made.", - "experimental": true, - "optional": true, - "$ref": "ExecutionContextId" - } - ] - } - ] - }, - { - "domain": "NodeWorker", - "description": "Implemented partly just because of pesky vscode.", - "deprecated": true, - "commands": [ - { - "name": "enable", - "description": "Used to get the attachedToWorker event", - "parameters": [ ] - } - ], - "events": [ - { - "name": "attachedToWorker", - "description": "Issued when attached to a worker.", - "parameters": [ - { "name": "sessionId", - "description": "Identifier assigned to the session used to send/receive messages.", - "$ref": "string" - }, - { - "name": "workerInfo", - "type": "object", - "properties": [ - { "name": "workerId", - "$ref": "string" - }, - { "name": "type", - "type": "string" - }, - { "name": "title", - "type": "string" - }, - { "name": "url", - "type": "string" - } - ] - }, - { "name": "waitingForDebugger", - "type": "boolean" - } - ] } ] } diff --git a/src/me/topchetoeu/jscript/engine/debug/SimpleDebugger.java b/src/me/topchetoeu/jscript/engine/debug/SimpleDebugger.java index bee5428..7ed5946 100644 --- a/src/me/topchetoeu/jscript/engine/debug/SimpleDebugger.java +++ b/src/me/topchetoeu/jscript/engine/debug/SimpleDebugger.java @@ -31,6 +31,7 @@ import me.topchetoeu.jscript.json.JSONElement; import me.topchetoeu.jscript.json.JSONList; import me.topchetoeu.jscript.json.JSONMap; +// very simple indeed public class SimpleDebugger implements Debugger { public static final String CHROME_GET_PROP_FUNC = "function s(e){let t=this;const n=JSON.parse(e);for(let e=0,i=n.length;e>\",i=e.call(this,r);if(i!==r)return String(i)}catch(r){return`<>${JSON.stringify([String(r),\"object\"])}`}if(typeof this==\"object\"&&this){let r;for(let i of[Symbol.for(\"debug.description\"),Symbol.for(\"nodejs.util.inspect.custom\")])try{r=this[i]();break}catch{}if(!r&&!String(this.toString).includes(\"[native code]\")&&(r=String(this)),r&&!r.startsWith(\"[object \"))return r.length>=t?r.slice(0,t)+\"\\u2026\":r}\n ;\n\n}"; @@ -136,7 +137,7 @@ public class SimpleDebugger implements Debugger { } } - private class RunResult { + private static class RunResult { public final Context ctx; public final Object result; public final EngineException error; @@ -598,10 +599,10 @@ public class SimpleDebugger implements Debugger { if (obj != emptyObject) { for (var key : obj.keys(true)) { var propDesc = new JSONMap(); - + if (obj.properties.containsKey(key)) { var prop = obj.properties.get(key); - + propDesc.set("name", Values.toString(ctx, key)); if (prop.getter != null) propDesc.set("get", serializeObj(ctx, prop.getter)); if (prop.setter != null) propDesc.set("set", serializeObj(ctx, prop.setter));