{{+bindTo:partials.standard_devtools_article}}
Under the hood, Chrome Developer Tools is a web application written in HTML, JavaScript and CSS. It has a special binding available at JavaScript runtime that allows interacting with chrome pages and instrumenting them. Interaction protocol consists of commands that are sent to the page and events that the page is generating. Although Chrome Developer Tools is the only client of this protocol, there are ways for third parties to bypass it and start instrumenting browser pages explicitly. We will describe the ways it could be done below.
Note: If you are interested in inspecting remote pages on Chrome for Android, please see the remote debugging documentation. For users wishing to implement custom inspection code using our debugger protocol instead, please use the instructions below.
Interaction protocol consists of JSON commands that are sent to the page and events that the page is generating. We define this protocol in Blink ("upstream") so that any Blink-based browser supported it.
Protocol backwards compatibility is defined as follows:
There also is a tip-of-tree version of the protocol that reflects present state of the protocol in Blink repository. You can use it with Google Canary builds at your own risk. Note that unless tip of the tree revision is promoted to the draft, there is no backwards compatibility support guaranteed for the capabilities it introduces.
DevTools may introduce new features that are not currently documented under the tip-of-tree protocol documentation. You can discover these if you want to try using features, however, the undocumented protocol is volatile and may break at any time. First, inspect the inspector and reload the inspector so your attached one can view its WebSocket connection (Network > Filter > WebSockets
). Then view the frames of WebSocket activity as you use the host DevTools. You may need to re-click the WebSocket item to have the Frame activity update.
Today Developer Tools front-end can attach to a remotely running Chrome instance for debugging. For this scenario to work, you should start your host Chrome instance with the remote-debugging-port command line switch:
Then you can start a client Chrome instance, using a separate user profile:
And now you can navigate to the given port from your client and attach to any of the discovered tabs for debugging.
You will find Developer Tools interface identical to the embedded one and here is why:
In this scenario, you can substitute Developer Tools front-end with your own implementation. Instead of navigating to the HTML page at http://localhost:9222, your application can discover available pages by issuing the following HTTP request to the browser:
and getting a JSON object with information about inspectable pages along with the WebSocket addresses that you could use in order to start instrumenting them.
Note that we are currently working on exposing an HTTP-based protocol that does not require client WebSocket implementation.
Remote debugging is especially useful when debugging remote instances of the browser or attaching to the embedded devices. Blink port owners are responsible for exposing debugging connections to the external users.
To allow third parties to interact with the protocol, we introduced chrome.debugger extension API that exposes this JSON message transport interface. As a result, you can not only attach to the remotely running Chrome instance, but also instrument it from its own extension.
Chrome Debugger Extension API provides a higher level API where command
domain, name and body are provided explicitly in the sendCommand
call. This API hides request ids and handles binding of the request with its
response, hence allowing sendCommand
to report result in the
callback function call. One can also use this API in combination with the other
Extension APIs.
If you are developing a Web-based IDE, you should implement an extension that exposes debugging capabilities to your page and your IDE will be able to open pages with the target application, set breakpoints there, evaluate expressions in console, live edit JavaScript and CSS, display live DOM, network interaction and any other aspect that Developer Tools is instrumenting today.
Note: opening embedded Developer Tools will terminate the remote connection / detach the extension and will replace active debugger with itself. We are working on allowing several clients to instrument the page simultaneously.