Package Torello.Browser.JsonAST
Enum PropName
- java.lang.Object
-
- java.lang.Enum<PropName>
-
- Torello.Browser.JsonAST.PropName
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<PropName>
public enum PropName extends java.lang.Enum<PropName>
Enumerates the JSON property names that may appear within their JSON protocol definitions. These filesbrowser_protocol.jsonandjs_protocol.jsoncontain the full specs for each of these APIs.
Each constant represents a field that could be present when describing a domain, type, command, event, property, parameter or return-value. Instances of this enum are recorded in AST nodes to keep track of which properties were included. This enum, effectively, enables writing statistics & diagnostics about these two'.json'-Files about the protocol as a whole.
I have attempted to explain to Chat-GPT that the following enum is largely for your education, not because it's so important. This lives in an internal-use package (Torello.Browser.JsonAST) that nobody is expected to program against. Its job is to document how the parser reads Google's two CDP spec files, builds an AST, and then how that AST is walked to produce the Java types you actually use in theBrowserAPIandJavaScriptAPIpackages. In plain terms: this enum just names the JSON property keys you'll see in those files so we can talk about them clearly.
The fun here is exploratory: I lift a tiny JSON snippet out of a 30k-line protocol and surround it with links so you can click from the raw JSON → the AST nodes → the generated Java. Think of the hyperlinks as my System.out.println for documentation: follow them and you'll see what the parser sees. You do not need any of this to start remotely controlling a browser; this is a “Sunday read” for the curious who want to understand how stuff is made.
After Some Talk, Chat-GPT also wrote this Chunk-o-Stuff For me:
This content describes an internal documentation aid for the packageJsonAST. It is written primarily for readers who want to peek behind the curtain and see how the Chrome DevTools Protocol (CDP) JSON files are interpreted by the parser used in this project.
Practical note: This package is intended for internal use and is not expected to be generally useful as an external programming API.
WHAT THE PARSER DOES
The parser consumes two protocol-definition files published by Google:browser_protocol.jsonandjs_protocol.json. From these inputs it constructs an internalAST(Abstract Syntax Tree). That tree can be walked to generate the Java types that appear in the public-facing packagesBrowserAPIandJavaScriptAPI.
WHAT THIS ENUM IS
This file documents an enum whose constants enumerate all JSON Object property names that may occur in those two CDP specification files. In other words, each constant corresponds to a field name you can actually find inside a protocolJsonObject. This makes it easier to narrate how the raw JSON is recognized and organized during parsing.
WHY YOU MIGHT READ THIS
If you are the kind of reader who likes to trace how a six‑line JSON snippet turns into concrete Java, you can follow the hyperlinks here to jump between the JSON, the AST nodes, and the generated types. It’s an annotated tour of how Google’s protocol definitions become the Java WebSocket code that powers this project.
DO YOU NEED TO KNOW THIS?
No. You do not need any of this to start remotely controlling a web browser with the public APIs. This page exists for curiosity, auditing, and historical context.
If your goal is automation, you can go straight to the public packages:BrowserAPIandJavaScriptAPI.
Page originally drafted by ChatGPT on 2025-08-31.
Edited and formatted by Ralph Torello for use in the Torello Browser Tool documentation.
Hi-Lited Source-Code:- View Here: Torello/Browser/JsonAST/PropName.java
- Open New Browser-Tab: Torello/Browser/JsonAST/PropName.java
File Size: 4,468 Bytes Line Count: 139 '\n' Characters Found
-
-
Enum Constant Summary
JsonObject Property Names: Value Contains a Name for this Definition (3 Variants, Same Thing) Enum Constant Description DOMAINProtocol property"domain", the name of the domain that owns this definition.IDProtocol property"id", the unique identifier for a "type" definition.NAMEProtocol property"name", the identifier of aPPRor a "command" or "event".JsonObject Property Names: Primary Descriptive Stuffola Enum Constant Description $REFProtocol property"$ref", referencing another type definition by name.DESCRIPTIONProtocol property"description", free-form text documenting the definition.ITEMSProtocol property"items", defining the element type of an array schema.TYPEProtocol property"type", indicating the schema type of the value.JsonObject Property Names: Value Contains a JsonArray of TCE Definitions Enum Constant Description COMMANDSProtocol array"commands", listing all commands defined by a domain.EVENTSProtocol array"events", listing all events defined by a domain.TYPESProtocol array"types", containing schema type definitions for a domain.JsonObject Property Names: Value Contains a JsonArray of PPR Definitions Enum Constant Description PARAMETERSProtocol array"parameters", defining the inputs accepted by a command.PROPERTIESProtocol array"properties", defining the fields of an object type.RETURNSProtocol array"returns", defining the return values of a command.JsonObject Property Names: Value is just a Boolean Flag or Marker Enum Constant Description DEPRECATEDProtocol flag"deprecated", a boolean marker for obsolete definitions.EXPERIMENTALProtocol flag"experimental", a boolean marker for unstable or evolving features.OPTIONALProtocol flag"optional", a boolean marker for nullable parameters or properties.JsonObject Property Names: Other Enum Constant Description DEPENDENCIESProtocol array"dependencies", listing domains or types this one relies on.ENUMProtocol property"enum", enumerating the fixed literal values allowed.REDIRECTProtocol property"redirect", marking this type as an alias of another.
-
Method Summary
Convert String to Enum Constant Modifier and Type Method Description static PropNamevalueOf(String name)Returns the enum constant of this type with the specified name.List all Enum Constants Modifier and Type Method Description static PropName[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
TYPE
public static final PropName TYPE
Protocol property"type", indicating the schema type of the value.The salient line of JSON, in the example provided below, is:>> "type": "string"In this example JSON, which has been lifted from theAccessibility-Domain's JSON definition, the AST-Node generated by parsing thisJsonObject(the first object in Accessibility'stypesarray) will be aTCEinstance whosepropNamesfield contains the following constants:
ID, DESCRIPTION and TYPE
Java Script Object Notation (JSON):
"types": [ { "id": "AXNodeId", "description": "Unique accessibility node identifier.", "type": "string" }
Case Study · Accessibility.AXNodeId:
Above is an example JSON Snippet from theAccessibilityDomainthat contains a"type"Json-Property. The first element ofAccessibility'sTypes List is a Simplified-Type called'AXNodeId'. Because this Simplified-Type has a"type"Property which has been assigned the value"string", it is therefore a type that is just too simple to have been converted into a Java static Nested-Class.
As a result, the JsonAST Package Type-Simplifier eliminates what would otherwise be a nested class named'Accessibility.AXNodeId'. All references within the tree's nodes that refer toAXNodeIdare replaced with the Simplified Standard, out-of-the-box Java,java.lang.String.
If you navigate to the list of types defined within the package Browser-API to theAccessibility-Domain, you will notice that althought there is a Nested-Type namedAccessibility.AXNode, there is no such definition forAccessibility.AXNodeId. The actualbrowser_protocol.jsonJSON specification file, clearly, has definitions for classes with both of these names.Note that the aboveJsonObjectdoes indeed contain a property named"type". Thusly, theJsonAST.TCEinstance forAccessibility.AXNodeIdwill have an instance of this enum'sTYPEEnum-Constant among it'spropNameslist. If that sounds like unintelligible jargon, load up the Browser-API's 'AST', and look for the 'Accessibility' Domain. Afterwards, iterate the list of types defined in that domain'stypes-list.
You are guaranteed to find aTCE-Type whoseTCE.namefield equals"AXNodeId"(and also one forAXNode, but the JSON for that definition is not included in the sample JSON cut-and-pasted, above). Significantly, iterating the contents of theReadOnlyListofPropNames, you will find an instance of theTYPEEnum-Constant, precisely because"type"is one of theJsonObjectproperties included in this type's JSON definition.
AlthoughAXNodeIdis not one of the static Nested-Classes which is "reified" by the Code Generator, it will, indeed, have an AST Node in the Browser-API's AST Tree.
-
NAME
public static final PropName NAME
Protocol property"name", the identifier of aPPRor a "command" or "event".
The"name"property is the most commonly used property name amongst a group of threeJsonObjectProperty Names used to give a name to a particular node in the AST. TheDOMAINproperty-name gives a name toDomainnodes, and theIDproperty-name gives a name toTCEnodes (and specifically"type"TCE's, but not to"command"nor"event"TCE's). However, theNAMEproperty name allows for specifying a name to allPPRnodes, and furthermore is used to give a name to all"command"and"event"TCE's.The three different JSON Properties that, essentially, are doing the exact same thing are:"domain", "id"and"name".
-
ID
public static final PropName ID
Protocol property"id", the unique identifier for a "type" definition.The salient line of JSON, in the example provided below, is:>> "id": "Metric",In this example JSON, which has been lifted from thePerformance-Domain's JSON definition, the AST-Node generated by parsing thisJsonObject(the first object in Performance'stypesarray) will be aTCEinstance whosepropNamesfield contains the following constants:
ID, DESCRIPTION, TYPE and PROPERTIES
Java Script Object Notation (JSON):
{ "domain": "Performance", "types": [ { "id": "Metric", "description": "Run-time execution metric.", "type": "object", "properties": [ { "name": "name", "description": "Metric name.", "type": "string" }, { "name": "value", "description": "Metric value.", "type": "number" } ] } ],
Case Study · Performance.Metric:
Above is an example JSON Snippet from thePerformanceDomain. This domain has a nested class namedPerformance.Metricwhich is listed amongst the members of it's"types"array. This nested class has the name"Metric"m as is (hopefully) elucidated by the JSON"id"property.
What there is to know about the Json Property named"id"is that it is always used to provide the exact name of a CDPtype(which are ultimately converted fromtypesinto Java nested classes). The table provided below attempts to show which properties are used to provide names for the different entities in this package:JSON Property Applicable Entities "domain" Domain"id" Type TCE(Nested Classes)"name" Everything Else, Including: Command & Event TCE'salong with all variants ofPPR.
What is important to know about the"id"JSON Property is that it is a member of a group of three different JSON Property Names that are used to identify and provide the name of aJsonObject. Because nested classes, or"types"are used throughout the CDP API, the name of the class becomes more than just a name, it is an actual identification which is used by the protocol to specify a type of any variable that is an instance of that type.
Thusly, while mostJsonObject'sin this protocol have a JSON"name"Property, elements of a"types"array have an"id"Property instead!The three different JSON Properties that, essentially, are doing the exact same thing are:"domain", "id"and"name".
-
DOMAIN
-
TYPES
-
COMMANDS
public static final PropName COMMANDS
Protocol array"commands", listing all commands defined by a domain.The salient line of JSON, in the example provided below, is:>> "commands": [This example JSON includes the entire definition for theDeviceOrientation-Domain. The AST-Node generated by parsing thisJsonObject(the 17th object listed in the main, top level, 'Domains' array) is going to be aDomainobject instance whosepropNamesfield contains the following constants:
DOMAIN, EXPERIMENTAL, COMMANDS
Java Script Object Notation (JSON):
{ "domain": "DeviceOrientation", "experimental": true, "commands": [ { "name": "clearDeviceOrientationOverride", "description": "Clears the overridden Device Orientation." }, { "name": "setDeviceOrientationOverride", "description": "Overrides the Device Orientation.", "parameters": [ { "name": "alpha", "description": "Mock alpha", "type": "number" }, { "name": "beta", "description": "Mock beta", "type": "number" }, { "name": "gamma", "description": "Mock gamma", "type": "number" } ] } ] }
Case Study · DeviceOrientation:
Buried within the Browser Protocol, theDeviceOrientationdomain defines exactly two commands in its"commands"array (and zero types or events within their respective arrays). You may view the generated Java for this domain here:DeviceOrientation. It may or may not be obvious, but this is likely the shortest domain definition amongst all domains in CDP. The JSON definition for theCSS-Domain spans several thousand linesl however, this entire thing weighs in at ~30 lines.
TheDeviceOrientationpublic API exposes the following two methods only, each corresponding 1:1 to a JSON 'command' (which has been listed in this"commands"array):
For a table view of these methods, in this domain's Java-Class, jump to the class'sMethod Summarysection.
-
EVENTS
-
PROPERTIES
public static final PropName PROPERTIES
Protocol array"properties", defining the fields of an object type.The salient line of JSON, in the example provided below, is:>> "properties": [
This example JSON includes a single property for one of the types listed in theRunTime-Domain. This domain is actually defined in the filejs_protocol.json, which is the JavaScript API definition file. The AST-Node generated by parsing thisJsonArrayis going to be a list ofPPRinstances. This example only lists the first property or field contained by the array.
Java Script Object Notation (JSON):
"properties": [ { "name": "serialization", "type": "string", "enum": [ "deep", "json", "idOnly" ] },
Case Study · RunTime.SerializationOptions.serialization:
TheRunTimedomain defines a static nested-class / inner-type namedRunTime.SerializationOptions. This nested class has exactly three fields in its definition. These field constitute the specialization options that the browser uses when serializing data. For brevity, the above imported JSON snippet only shows the first field or "property" in the class. This field shown above is one namedserialization
The JSON specification files for CDP do not actually use the word / term "field" for pieces of data which are affixed to nested classes; they use the term "property" (though theyt are identical to the Java 'fields' - variables defined inside of a class object). The acronymPPRactually stands for "Properties, Parameters & Returns". In the Java HTML CDP implementation, when an instance ofPPRcontains a list of datum that were ascribed to a static inner class, those datum are extracted from a JSON array whose property name is'properties'
Interestingly, when a data value is affixed to a method / command input parameter, it shall be listed in aJsonArraywhose property name isparameters. And when a piece of data is attached to the output of a method / command, it will be listed in aJsonArraynamedreturns.
This'serialization'field for theRunTime.SerializationOptionsnested class is astringtype. More importantly, the values which the CDP API permits be assigned to thisstringare restricted to the contents listed in theenumfield. Specifically, whenever Google Chrome passes a response with theSerializationOptionsnested class in it, the values assigned to theserializationfield will be restricted to one of these three:"deep", "json" & "idOnly"
-
PARAMETERS
public static final PropName PARAMETERS
Protocol array"parameters", defining the inputs accepted by a command.The salient line of JSON, in the example provided below, is:>> "parameters": [
This example JSON includes the entire definition for theDebugger-Domain. which is actually defined in thejs_protocol.json(JavaScript API) definition JSON File. The AST-Node generated by parsing thisJsonArrayis going to be a list ofPPRinstances of length two. In this particular example every input parameter to the methodcontinueToLocationis shown.
Java Script Object Notation (JSON):
"commands": [ { "name": "continueToLocation", "description": "Continues execution until specific location is reached.", "parameters": [ { "name": "location", "description": "Location to continue to.", "$ref": "Location" }, { "name": "targetCallFrames", "optional": true, "type": "string", "enum": [ "any", "current" ] } ] },
Case Study · Debugger.continueToLocation:
-
RETURNS
-
OPTIONAL
public static final PropName OPTIONAL
Protocol flag"optional", a boolean marker for nullable parameters or properties. The'optional'flag is a boolean marker on protocol parameters and event fields. It behaves likeEXPERIMENTALin that it is simply present or absent in the JSON.
Semantics: properties adorned with this flag may be omitted (“elided”). In the generated Java, this maps tonull-able types, hence the widespread use of boxed primitives (java.lang.Integer,java.lang.Boolean, …) in the generated BrowserAPI/JavaScriptAPI classes. Callers may passnull; receivers must be prepared to readnull, even for “simple” values.
-
EXPERIMENTAL
public static final PropName EXPERIMENTAL
Protocol flag"experimental", a boolean marker for unstable or evolving features.The salient line of JSON, in the example provided below, is:>> "experimental": trueIn this example JSON, which has been lifted from theDOMDebugger-Domain's JSON definition, the AST-Node generated by parsing thisJsonObject(the second object inDOMDebugger.removeEventListenerBreakpoint()'sparametersarray) will be aPPRinstance whosepropNamesfield contains the following constants:
NAME, DESCRIPTION, EXPERIMENTAL, OPTIONAL and TYPE
Java Script Object Notation (JSON):
{ "name": "removeEventListenerBreakpoint", "description": "Removes breakpoint on particular DOM event.", "parameters": [ { "name": "eventName", "description": "Event name.", "type": "string" }, { "name": "targetName", "description": "EventTarget interface name.", "experimental": true, "optional": true, "type": "string" } ] }
Case Study · DOMDebugger.removeEventListenerBreakpoint:
The included JSON snippet is a clip from the list of "commands" (JSON defined 'commands' are transpiled into standard Java methods) contained within theDOMDebugger-Domain. The snippet, above, is aJsonObjectthat is the third object listed in the 'commands' array. You may view the Java that is ultimately generated using this Json here, in the method simply namdremoveEventListenerBreakpoint. The contents therein are what that Json Definition turns into after being 'reified' into an actual concrete method.
Load the AST for the Browser-API from the Java-HTML'.jar'File into memoryspace, and search for theDOMDebugger-Domain. Once you have the actualDomainreference, you may then search and iterate the contents of thecommandsRead-Only List, until you have located aTCEinstance whosenameis equal to'removeEventListenerBreakpoint'.
Once you have identified the AST Node for this command, you should next iterate the list ofparametersuntil you have found one whosenameis equal to'targetName'. This is the exact parameter that has been emitted by the code generator based on the Json-Snippet which has been hilited, and posted, in the example above. Make sure to go ahead and check the contents of thepropNamesRead-Only List contained by thatparameter. You are guaranteed to find an instance of this enum constant,PropName.EXPERIMENTAL.Flag Meaning: Features, Commands, Types, etc... which are products of Google's Chrome DevTools Protocol that have been marked as Experimental are features that are presently available, but not yet considered stable. They may change in behavior, be renamed, or even disappear entirely in future versions of the protocol. In short, "Experimental" means usable for testing and exploration, but not something to rely on for long-term compatibility.
-
DEPRECATED
public static final PropName DEPRECATED
Protocol flag"deprecated", a boolean marker for obsolete definitions.
-
DESCRIPTION
public static final PropName DESCRIPTION
Protocol property"description", free-form text documenting the definition.The salient line of JSON, in the example provided below, is the one that begins with:>> "description": "RunTime domain exposes JavaScript runtime by means of remote evaluation and mirror objects...",In this example JSON, which has been extracted from the JavaScript API's spec file,js_protocol.json, theRunTime-Domain's initial JSON definition is provided. TheDomainAST Node will have apropNamesfield that contains the following constants:
DOMAIN, DESCRIPTION, TYPES, COMMANDS (not visible below) and EVENTS (also not visible here)
Java Script Object Notation (JSON):
{ "domain": "RunTime", "description": "RunTime domain exposes JavaScript runtime by means of remote evaluation and mirror objects.\nEvaluation results are returned as mirror object that expose object type, string representation\nand unique identifier that can be used for further object reference. Original objects are\nmaintained in memory unless they are either explicitly released or are released along with the\nother objects in their object group.", "types": [ { "id": "ScriptId", ...
Case Study · RunTime Domain:
Above is an example JSON snippet from theRunTimeDomain. The official specification defines this domain using the name"Runtime". However, due to a significant name clash with the standard Java classjava.lang.Runtime, this class' name has been deliberately changed to RunTime (with a capital 'T').
The JSON property"description"appears ubiquitously throughout both JSON spec files (browser_protocol.jsonandjs_protocol.json). It is used to provide a short explanation of the use or purpose of a:
-
DEPENDENCIES
public static final PropName DEPENDENCIES
Protocol array"dependencies", listing domains or types this one relies on.The salient line of JSON, in the example provided below, is:>> "dependencies": [In this example JSON, which has been copied from thePerformanceTimeline-Domain's JSON definition. ThisDomainAST Node will have apropNamesfield contains the following constants:
DOMAIN, DESCRIPTION, EXPERIMENTAL, DEPENDENCIES, TYPES, COMMANDS (not visible below) and EVENTS (also not visible here)
Java Script Object Notation (JSON):
{ "domain": "PerformanceTimeline", "description": "Reporting of performance timeline events, as specified in\nhttps://w3c.github.io/performance-timeline/#dom-performanceobserver.", "experimental": true, "dependencies": [ "DOM", "Network" ], "types": [ { "id": "LargestContentfulPaint", ...
Case Study · PerformanceTimeline:
Above is an example JSON Snippet from thePerformanceTimelineDomain. If you'll notice, there is a JSON Property, above, simply named"dependencies". TheJsonASTpackage will parse and extract this list of "dependent domain's", and convert (link) this list ofStringsinto aReadOnlyListofDomaininstances. (The step or process of converting types which have been specified usingJsonString'sinto actual Object References is usually just called "linking the types" or "linking the variables").
It should be somewhat significant to know that the"dependencies"JSON Property is not actually used by anything at all in this library!. This property is output & emitted by the CDP Specs, but AFAIK (as far as I know), it has really only been included for informational purposes and 'posterity'.
There is aprivatefield which is defined in theDomainAST Node, whose name isdependencies. This private field's value can be retrieved from the domain by invoking'getDependencies()'. All taht this field is just a list of references to the actual domains listed in this JSON array property. Note that the actual processing code that extracts this information is no more than two or three LOC itself. Because it literally causes "no overhead at all" (in terms of compute cycles), this list is indeed parsed and linked into a list of actual domain object refernces; and saved to an internal read-only list.
This is despite the fact that it's never used anywhere in the code itself.
Also, it is important to know that the actual, generated, Java code (by the Code Generator) for thePerformanceTimelinedomain may seem like it could possibly have to add a few Java 'import' statements. (Maybe? That's what this proprty is for?) But a las, even a simple inclusion such as an'import DOM.*;'statement is just completely unnecessary & superfluous here. Whatever actual dependencies exist will be analyzed by'javac'(when you compile your code), or will be analyzed by something hidden, completely, behind the Web-Socket Layer inside of Google Chrome, itself.
Either way, there is just no reason, whatsoever, to worry about the purpose of the"dependencies"property at all.Perhaps the authors of theChrome DevTools Protocol@ Google will one day explain how these 'dependencies' relate to the types, commands and event types in the various domains that employ this property. However, as of today this list is wholly un-used.
-
ENUM
-
ITEMS
public static final PropName ITEMS
Protocol property"items", defining the element type of an array schema.The salient line of JSON, in the example provided below, is:>> "items": {In this example JSON, which has been extracted from theLayerTree-Domain'sLayerTree.LayerJSON definition, thisTCEAST Node will have apropNamesfield that contains the following constants:
NAME, DESCRIPTION, OPTIONAL, TYPE and ITEMS
Java Script Object Notation (JSON):
{ "name": "transform", "description": "Transformation matrix for layer, default is identity matrix", "optional": true, "type": "array", "items": { "type": "number" } },
Case Study · LayerTree.Layer 'transform' Field:
Above is an example JSON snippet from theLayerTreeDomain. The JSON snippet shows a field that's a member of the nested (inner) classLayerTree.Layer. If you click that link, you will see all fields that are members of the nested classLayer, including the array-typed field namedtransform.
The field is an'optional'field, meaning thatnullcan be assigned to its value, and the browser will be able to execute the requested operation without error. It also means that if an instance of this class is returned by Chrome from a method call, this field may or may not be assigned a value (i.e., it may benull).
What is also significant about this field is that it is designated as an array of the Java boxed typejava.lang.Number. Chrome indicates that JSON values of typenumbermay be integral or floating-point.
Notice in the JSON above that thetypeof the field is asserted to be'array', but the word'array'does not by itself specify the component (base) type of the array. That role is served by the'items'JSON property.
If you scan the contents ofbrowser_protocol.json, which is the spec file that defines the Chrome Browser API, and useeitherthe search string"items"orthe search string"array", you will notice that these two JSON properties effectively function as a pair. Whenever aTCEor aPPRis defined as anarray, the very next JSON property is typicallyitems— defining the array's component type.
-
REDIRECT
-
$REF
-
-
Method Detail
-
values
public static PropName[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (PropName c : PropName.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static PropName valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
-