Package Torello.Browser.JavaScriptAPI
Chrome DevTools Protocol – JavaScript & Runtime Domains
This package contains Java wrappers for CDP domains related to JavaScript execution and runtime behavior inside the browser. These domains include:
In real-world usage, the vast majority of this package boils down to one method:
RunTime.evaluate
This command executes arbitrary JavaScript code inside a live tab and returns the result. This method was the original impetus for writing even a single line of the
Torello.Browser
package and its sub-packages.
The author of this package does not claim to understand the full CDP specification. In fact, the Java bindings here were created primarily to support a single use case: triggering the execution of "Page Load" JavaScript on dynamic websites so that content could be extracted afterward. Static HTML scraping was no longer viable. In the world of Data Science & Web Scraping — collecting data from JavaScript-heavy web pages requires a real way to execute JavaScript inside a Java program, without manually opening a browser and using your hands to point, click, & download.
Mere JSON-Wrappers:
The classes found in
Torello.Browser.BrowserAPI and
Torello.Browser.JavaScriptAPI perform **no browser processing** of any kind —
zero. They are nothing more than structural glue that converts between Java and JSON. These
classes are purely data transformers: they take Java-Typed Method-Arguments, which have been
supplied by the user, marshal them into Chrome-Compatible JSON-Payloads, and return
Script objects that have the capability to send
this JSON-Request over a WebSocket. This is
is executed by invoking the Script.exec(...)
method. This method returns a Promise object.
When the browser replies, the
Promise
instance that was just returned by exec()
will perform the specified JSON-Response processing. That promise receives the
JSON-Response and un-marshals it — i.e., extracts typed Java values from the JSON
structure — returning them as usable Java-Types back to the caller. That's it. That’s the whole
process.
Important: These classes do **not** implement any control
logic, flow logic, decision trees, emulation, validation, or browser-side semantics. There is
no intelligence or conditionality in these files — not even simple logic like error checks
or null guards. Their one and only job is listed here, below.
- Generate JSON from typed Java parameters
- Return a
Scriptobject that contains & encapsulates BOTH the JSON-Request AND a response handler, within - Parse JSON responses from Chrome and extract typed Java results
Asking for Help:
Best Practice: If you're trying to figure out what
Chat-GPT, in particular, has been the LLM that has demonstrated an expert level of knowledge in the use of Google's Chrome-Browser Exported API. Moreover, explaining to this particular LLM that the
RunTime.callFunctionOn
or
Debugger.setBreakpointByUrl
actually do — the best option is to ask Chat-GPT. That is, quite literally, how most of this
package's documentation has been written; and more importantly, the only real way to get to
know Google's Auto-Generated CDP API (unless you are already familiar with Google's CDP
Project!). See Also:
Chrome DevTools Protcol
on GitHub.
Chat-GPT, in particular, has been the LLM that has demonstrated an expert level of knowledge in the use of Google's Chrome-Browser Exported API. Moreover, explaining to this particular LLM that the
Torello.Browser package is simply auto-generating
JSON-Wrappers to connect Java (over WebSockets) to the browser has been extremely simple and
refreshing — Chat-GPT seemed to understand exactly what I was
doing. It practically knew better than I, what I was doing! It was, perspicaciously,
explaining to me how my own utility / tool works!
Google's official DevTools documentation lacks clear examples, and few people in the Java ecosystem work with CDP directly. These wrappers were built to give structure to a protocol that otherwise resists understanding.
Page originally drafted by ChatGPT on 2025-08-02.
Edited and formatted for use in Chrome DevTools Protocol Documentation.
-
Primary Domain Classes Java Entity Description Console This domain is deprecated - use RunTime or Log insteadDebugger Debugger domain exposes JavaScript debugging capabilitiesHeapProfiler [No Description Provided by Google]Profiler [No Description Provided by Google]RunTime RunTime domain exposes JavaScript runtime by means of remote evaluation and mirror objectsSchema This domain is deprecatedConsole Domain Types Java Entity Description Console.ConsoleMessage Console messageConsole Domain Events Java Entity Description Console.messageAdded Issued when new console message is addedDebugger Domain Types Java Entity Description Debugger.BreakLocation [No Description Provided by Google]Debugger.CallFrame JavaScript call frameDebugger.DebugSymbols Debug symbols available for a wasm scriptDebugger.Location Location in the source codeDebugger.LocationRange Location range within one scriptDebugger.ResolvedBreakpoint [No Description Provided by Google]Debugger.Scope Scope descriptionDebugger.ScriptPosition Location in the source codeDebugger.SearchMatch Search match for resourceDebugger.WasmDisassemblyChunk [No Description Provided by Google]Debugger Domain Command Return-Types Java Entity Description Debugger.disassembleWasmModule$$RET [No Description Provided by Google]Debugger.evaluateOnCallFrame$$RET Evaluates expression on a given call frameDebugger.getScriptSource$$RET Returns source for the script with given idDebugger.restartFrame$$RET Restarts particular call frame from the beginningDebugger.setBreakpoint$$RET Sets JavaScript breakpoint at a given locationDebugger.setBreakpointByUrl$$RET Sets JavaScript breakpoint at given location specified either by URL or URL regexDebugger.setScriptSource$$RET Edits JavaScript source liveDebugger Domain Events Java Entity Description Debugger.breakpointResolved Fired when breakpoint is resolved to an actual script and locationDebugger.paused Fired when the virtual machine stopped on breakpoint or exception or any other stop criteriaDebugger.scriptFailedToParse Fired when virtual machine fails to parse the scriptDebugger.scriptParsed Fired when virtual machine parses scriptHeapProfiler Domain Types Java Entity Description HeapProfiler.SamplingHeapProfile Sampling profileHeapProfiler.SamplingHeapProfileNode Sampling Heap Profile nodeHeapProfiler.SamplingHeapProfileSample A single sample from a sampling profileHeapProfiler Domain Events Java Entity Description HeapProfiler.addHeapSnapshotChunk [No Description Provided by Google]HeapProfiler.heapStatsUpdate If heap objects tracking has been started then backend may send update for one or more fragmentsHeapProfiler.lastSeenObjectId If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestampHeapProfiler.reportHeapSnapshotProgress [No Description Provided by Google]Profiler Domain Types Java Entity Description Profiler.CoverageRange Coverage data for a source rangeProfiler.FunctionCoverage Coverage data for a JavaScript functionProfiler.PositionTickInfo Specifies a number of samples attributed to a certain source positionProfiler.Profile ProfileProfiler.ProfileNode Profile nodeProfiler.ScriptCoverage Coverage data for a JavaScript scriptProfiler Domain Command Return-Types Java Entity Description Profiler.takePreciseCoverage$$RET Collect coverage data for the current isolate, and resets execution countersProfiler Domain Events Java Entity Description Profiler.consoleProfileFinished [No Description Provided by Google]Profiler.consoleProfileStarted Sent when new profile recording is started using consoleProfiler.preciseCoverageDeltaUpdate Reports coverage delta since the last poll (either from an event like this, or fromtakePreciseCoveragefor the current isolateRunTime Domain Types Java Entity Description RunTime.CallArgument Represents function call argumentRunTime.CallFrame Stack entry for runtime errors and assertionsRunTime.CustomPreview [No Description Provided by Google]RunTime.DeepSerializedValue Represents deep serialized valueRunTime.EntryPreview [No Description Provided by Google]RunTime.ExceptionDetails Detailed information about exception (or error) that was thrown during script compilation or executionRunTime.ExecutionContextDescription Description of an isolated worldRunTime.InternalPropertyDescriptor Object internal property descriptorRunTime.ObjectPreview Object containing abbreviated remote object valueRunTime.PrivatePropertyDescriptor Object private field descriptorRunTime.PropertyDescriptor Object property descriptorRunTime.PropertyPreview [No Description Provided by Google]RunTime.RemoteObject Mirror object referencing original JavaScript objectRunTime.SerializationOptions Represents options for serializationRunTime.StackTrace Call frames for assertions or error messagesRunTime.StackTraceId IfdebuggerIdis set stack trace comes from another debugger and can be resolved thereRunTime Domain Command Return-Types Java Entity Description RunTime.awaitPromise$$RET Add handler to promise with given promise object idRunTime.callFunctionOn$$RET Calls function with given declaration on the given objectRunTime.compileScript$$RET Compiles expressionRunTime.evaluate$$RET Evaluates expression on global objectRunTime.getHeapUsage$$RET Returns the JavaScript heap usageRunTime.getProperties$$RET Returns properties of a given objectRunTime.runScript$$RET Runs script with given id in a given contextRunTime Domain Events Java Entity Description RunTime.bindingCalled Notification is issued every time when binding is calledRunTime.consoleAPICalled Issued when console API was calledRunTime.exceptionRevoked Issued when unhandled exception was revokedRunTime.exceptionThrown Issued when exception was thrown and unhandledRunTime.executionContextCreated Issued when new execution context is createdRunTime.executionContextDestroyed Issued when execution context is destroyedRunTime.inspectRequested Issued when object should be inspected (for example, as a result of inspect() command line API call)Schema Domain Types Java Entity Description Schema.Domain Description of the protocol domain