DevTools Protocol - Whats the difference between Target.getTargets and requesting the /json endpoint?

557 views Asked by At

According to the Chrome DevTools protocol viewer page:

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 requesting: http://localhost:9222/json 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.

However, according to the the Target Domain documentation, sending a message (via websockets) with {"method": "Target.getTargets"} returns a "list of available targets":

Target.getTargets # Retrieves a list of available targets.

RETURN OBJECT:

targetInfos array [ TargetInfo ]: The list of targets.

What is the difference?

1

There are 1 answers

0
Michael Ward On

Per aslushnikov's answer on the GH issue:

The Target domain is a modern and recommended way to explore targets. It also allows to communicate with multiple targets only a single connection.

Followed by:

The /json endpoint is an old way to explore and connect to targets.

Essentially, both seem to be fine; however, my take away is that using the Target.getTargets method is newly preferred