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
Script
object 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 messageDebugger Domain Types Java Entity Description Debugger.Scope Scope descriptionDebugger.WasmDisassemblyChunk [No Description Provided by Google]
Debugger.DebugSymbols Debug symbols available for a wasm scriptDebugger.CallFrame JavaScript call frameDebugger.ResolvedBreakpoint [No Description Provided by Google]
Debugger.ScriptPosition Location in the source codeDebugger.LocationRange Location range within one scriptDebugger.BreakLocation [No Description Provided by Google]
Debugger.Location Location in the source codeDebugger.SearchMatch Search match for resourceHeapProfiler Domain Types Java Entity Description HeapProfiler.SamplingHeapProfileNode Sampling Heap Profile nodeHeapProfiler.SamplingHeapProfile Sampling profileHeapProfiler.SamplingHeapProfileSample A single sample from a sampling profileProfiler Domain Types Java Entity Description Profiler.ProfileNode Profile nodeProfiler.FunctionCoverage Coverage data for a JavaScript functionProfiler.CoverageRange Coverage data for a source rangeProfiler.Profile ProfileProfiler.PositionTickInfo Specifies a number of samples attributed to a certain source positionProfiler.ScriptCoverage Coverage data for a JavaScript scriptRunTime Domain Types Java Entity Description RunTime.ExecutionContextDescription Description of an isolated worldRunTime.PrivatePropertyDescriptor Object private field descriptorRunTime.DeepSerializedValue Represents deep serialized valueRunTime.StackTrace Call frames for assertions or error messagesRunTime.CustomPreview [No Description Provided by Google]
RunTime.SerializationOptions Represents options for serializationRunTime.PropertyPreview [No Description Provided by Google]
RunTime.ExceptionDetails Detailed information about exception (or error) that was thrown during script compilation or executionRunTime.RemoteObject Mirror object referencing original JavaScript objectRunTime.StackTraceId IfdebuggerId
is set stack trace comes from another debugger and can be resolved thereRunTime.CallFrame Stack entry for runtime errors and assertionsRunTime.CallArgument Represents function call argumentRunTime.ObjectPreview Object containing abbreviated remote object valueRunTime.InternalPropertyDescriptor Object internal property descriptorRunTime.EntryPreview [No Description Provided by Google]
RunTime.PropertyDescriptor Object property descriptorSchema Domain Types Java Entity Description Schema.Domain Description of the protocol domainConsole Domain Events Java Entity Description Console.messageAdded Issued when new console message is addedDebugger Domain Events Java Entity Description Debugger.scriptParsed Fired when virtual machine parses scriptDebugger.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.resumed Fired when the virtual machine resumed executionDebugger.scriptFailedToParse Fired when virtual machine fails to parse the scriptHeapProfiler Domain Events Java Entity Description HeapProfiler.reportHeapSnapshotProgress [No Description Provided by Google]
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.resetProfiles -
This is Marker-EventHeapProfiler.lastSeenObjectId If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestampProfiler 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 fromtakePreciseCoverage
for the current isolateRunTime Domain Events Java Entity Description RunTime.inspectRequested Issued when object should be inspected (for example, as a result of inspect() command line API call)RunTime.executionContextsCleared Issued when all executionContexts were cleared in browser
This is Marker-EventRunTime.consoleAPICalled Issued when console API was calledRunTime.exceptionRevoked Issued when unhandled exception was revokedRunTime.executionContextCreated Issued when new execution context is createdRunTime.bindingCalled Notification is issued every time when binding is calledRunTime.exceptionThrown Issued when exception was thrown and unhandledRunTime.executionContextDestroyed Issued when execution context is destroyed