The Chromium Framework currently integrates 11 domains, covering 196 commands from the Chrome DevTools Protocol (CDP). While only a subset of the full protocol is implemented, developers can invoke any domain or method by calling the following alternative Procedure:
Cr_WebSocket_Command(Connection, EventID, Method.s, Params.s = #Null$)
Each command requires a Connection, an Event ID, and a Method. The Parameters argument is optional and defaults to #Null$ if omitted.
Example Code:
Params$ = #DQUOTE$ + "features" + #DQUOTE$ + ":[{" +
#DQUOTE$ + "name" + #DQUOTE$ + ":" + #DQUOTE$ + "prefers-color-scheme" + #DQUOTE$ + "," +
#DQUOTE$ + "value" + #DQUOTE$ + ":" + #DQUOTE$ + "light" + #DQUOTE$ +
"}]"
Cr_WebSocket_Command(Connection, 123456, "Emulation.setEmulatedMedia", Params$)
Commands for interacting with browser-level features such as permissions, windows, and downloads.
Read and write CSS stylesheets, rules, and styles, and track computed style updates.
Access and manipulate the document structure of a webpage.
Simulate device and environmental conditions such as screen size and geolocation.
Manage network requests, authentication challenges, and response handling.
Simulate user input such as keyboard events, mouse interactions, and text entry.
Control caching, cookies, headers, and user-agent behavior.
Highlight, display, or hide elements on a web page for debugging and visual inspection.
Comprehensive commands for page lifecycle, rendering, navigation, and scripting operations.
Execute and manage JavaScript code, bindings, and scripts within the target environment.
Attach to, manage, or control different browser targets such as tabs or extensions.
Executing a command from a specific domain is generally simpler than using the
Cr_WebSocket_Command() procedure directly. Each command mirrors the method name,
with the domain and command separated by an underscore.
List in PureBasic.Without Optional Parameters:
Page_CaptureScreenshot(Connection, #UE_Page_CaptureScreenshot)
With Optional Parameters:
NewList params_data.PARAMS_DATA()
AddElement(params_data())
params_data()\Name = "clip"
params_data()\Type = #Cr_DataType_Object
params_data()\Input = "{" +
#DQUOTE$ + "x" + #DQUOTE$ + ":0," +
#DQUOTE$ + "y" + #DQUOTE$ + ":0," +
#DQUOTE$ + "width" + #DQUOTE$ + ":" + Str(Width) + "," +
#DQUOTE$ + "height" + #DQUOTE$ + ":" + Str(Height) + "," +
#DQUOTE$ + "scale" + #DQUOTE$ + ":" + StrF(Scale, 2) +
"}"
AddElement(params_data())
params_data()\Name = "captureBeyondViewport"
params_data()\Type = #Cr_DataType_Boolean
params_data()\Input = "true"
Page_CaptureScreenshot(Connection, #UE_Page_CaptureScreenshot, params_data())