Microsoft Edge (Chromium) DevTools 协议概述Microsoft Edge (Chromium) DevTools Protocol overview

随着 Microsoft Edge 的基础 Web 平台Chromium,Microsoft Edge (EdgeHTML) DevTools 协议将不会接收任何进一步的更新。With the shift in the underlying web platform of Microsoft Edge to Chromium, the Microsoft Edge (EdgeHTML) DevTools Protocol will not be receiving any further updates. The Microsoft Edge \ (Chromium) DevTools Protocol will match the API of the Chrome DevTools Protocol going.The Microsoft Edge (Chromium) DevTools Protocol will match the APIs of the Chrome DevTools Protocol going forward.

可以通过引用 Chrome DevTools协议查看器来查找有关这些域和方法的文档。You can find documentation on those domains and methods by referring to the Chrome DevTools Protocol Viewer.

备注

ms Microsoft Edge (EdgeHTML) DevTools协议中前缀的任何方法在 Microsoft Edge \ (Chromium) DevTools 协议中不再受支持。Any methods that were prefixed with ms in the Microsoft Edge (EdgeHTML) DevTools Protocol are no longer supported in the Microsoft Edge (Chromium) DevTools Protocol.

使用 DevTools 协议Using the DevTools Protocol

下面将了解如何将自定义工具客户端附加到 Microsoft Edge \ (Chromium) 中的 DevTools Server。Here's how to attach a custom tooling client to the DevTools Server in Microsoft Edge (Chromium).

  1. 确保关闭 \Microsoft Edge \ (Chromium) 的所有实例。Ensure all instances of Microsoft Edge (Chromium) are closed.

  2. 启动Microsoft Edge调试 (Chromium) 调试端口:。Launch Microsoft Edge (Chromium) with the remote debugging port:.

    msedge.exe --remote-debugging-port=9222
    
  3. (可选)如果需要,可以使用不同的用户配置文件启动单独的 Edge 实例。Optionally, you can start a separate instance of Edge using a distinct user profile if desired.

    msedge.exe --user-data-dir=<some directory>
    
  4. 接下来,使用 HTTP list 终结点获取可附加页面目标的列表。Next, use the HTTP list endpoint to get a list of attachable page targets.

    http://localhost:9222/json/list
    
  5. 最后,通过 DevTools Web 套接字服务器连接到所需目标的 并发出命令 webSocketDebuggerUrl /订阅事件消息。Finally, connect to the webSocketDebuggerUrl of the desired target and issue commands/subscribe to event messages through the DevTools web socket server.

DevTools 协议 HTTP 终结点DevTools Protocol HTTP Endpoints

Microsoft Edge \ (Chromium) DevTools 协议支持以下 HTTP 终结点。The Microsoft Edge (Chromium) DevTools Protocol supports the following HTTP endpoints.

/json/version/json/version

提供有关主机的浏览器及其支持的 DevTools 协议的哪个版本的信息。Provides information on the browser of the host machine and which version of the DevTools Protocol it supports.

参数Parameters

None

Return 对象Return object

{
   "Browser": "Edg/75.0.115.0",
   "Protocol-Version": "1.3",
   "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3739.0 Safari/537.36 Edg/75.0.115.0",
   "V8-Version": "7.5.98",
   "WebKit-Version": "537.36 (@68a98f73c7d0f766fb5a013ea7f8dbb41089bc1b)",
   "webSocketDebuggerUrl": "ws://localhost:9222/devtools/browser/a9d0e8cf-476a-4a89-bba9-0fc27ce691cd"
}

/json/protocol/json/protocol

提供序列化为 JSON 的整个协议 API 图面。Provides the entire protocol API surface serialized as JSON.

参数Parameters

None

Return 对象Return object

表示协议当前版本的可用 API 图面的 JSON 对象。JSON object which represents the available API surface for current version of the protocol.

/json/list/json/list

提供用于调试的页面目标的候选列表。Provides a candidate list of page targets for debugging.

参数Parameters

None

Return 对象Return object

[{
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/AB07C11A262D1EC8634EB12E2DCA4989",
   "id": "AB07C11A262D1EC8634EB12E2DCA4989",
   "title": "localhost:9222/json/protocol",
   "type": "page",
   "url": "http://localhost:9222/json/list",
   "webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/AB07C11A262D1EC8634EB12E2DCA4989"
}, ...  ]

/json/close/json/close

关闭目标进程 \ (例如,在 Microsoft Edge \ (Chromium) 中,关闭页面选项卡) 。Closes down the target process (for example, in Microsoft Edge (Chromium), closes the page tab).

参数Parameters

目标 IDTarget ID

Return 对象Return object

String(“Target is closing”)

Microsoft Edge 适用的远程工具 (Beta)Remote Tools for Microsoft Edge (Beta)

现在,你可以从 Microsoft Store 安装Microsoft Edge (Beta) 远程Microsoft Store。You are now able to install the Remote Tools for Microsoft Edge (Beta) from the Microsoft Store. 此应用使你能够远程调试Microsoft Edge (Chromium) 计算机在Windows 10设备上运行的设备。This app enables you to remotely debug Microsoft Edge (Chromium) running on a Windows 10 device from your development machine.

若要了解如何设置 Windows 10 设备,以及如何从开发计算机连接到该设备,请导航到入门远程调试Windows 10设备"。To learn how to set up your Windows 10 device and connect to it from your development machine, navigate to Get Started with Remote Debugging Windows 10 Devices.

Microsoft Edge (Beta) 的远程工具使用与 DevTools 相同的 Microsoft Edge (Chromium) DevTools协议与在要调试的 Windows 10 设备上运行的 Microsoft Edge 进行通信。The Remote Tools for Microsoft Edge (Beta) uses the same Microsoft Edge (Chromium) DevTools Protocol as the DevTools to communicate with Microsoft Edge running on the Windows 10 device you want to debug. 每次调用协议之前,此应用程序只是预先 () /msedge/ pid 进程 ID。This app just prepends /msedge/ and a process ID (pid) before each call to the protocol. 它支持以下 HTTP 终结点。It supports the following HTTP endpoints.

/msedge/json/list/msedge/json/list

提供所有进程 \ (包括 PBA 和 Microsoft Edge) 的所有实例中所有选项卡的候选 msedge.exe Windows 10,以便进行调试。 Provides a candidate list of all msedge.exe processes (including PWAs and all tabs in all instances of Microsoft Edge) on the Windows 10 device for debugging.

参数Parameters

None

Return 对象Return object

[{
   "description": "",
    "devtoolsFrontendUrl": "http://172.17.75.195:80/msedge/7264/devtools/inspector.html?ws=172.17.75.195:80/msedge/7264/devtools/page/ED4FFDB4529723A0FAFCBDB9B45851BB",
    "faviconUrl": "https://docs.microsoft.com/favicon.ico",
    "id": "ED4FFDB4529723A0FAFCBDB9B45851BB",
    "title": "Get Started with Remote Debugging Windows 10 Devices - Microsoft Edge Development | Microsoft Docs",
    "type": "page",
    "url": "https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/remote-debugging/windows",
    "webSocketDebuggerUrl": "ws://172.17.75.195:80/msedge/7264/devtools/page/ED4FFDB4529723A0FAFCBDB9B45851BB",
    "browserProcessId": 7264
}, ...  ]

/msedge//msedge/

在功能上等同于 /msedge/json/listFunctionally equivalent to /msedge/json/list.

/msedge/[pid]/json/list/msedge/[pid]/json/list

提供与提供的用于调试的 Microsoft Edge 匹配的候选页面目标 [pid] 列表。Provides a candidate list of page targets for the Microsoft Edge instance that matches the provided [pid] for debugging.

参数Parameters

None

Return 对象Return object

[{
    "description": "",
    "devtoolsFrontendUrl": "http://172.17.75.195:80/msedge/7264/devtools/inspector.html?ws=172.17.75.195:80/msedge/7264/devtools/page/ED4FFDB4529723A0FAFCBDB9B45851BB",
    "faviconUrl": "https://docs.microsoft.com/favicon.ico",
    "id": "ED4FFDB4529723A0FAFCBDB9B45851BB",
    "title": "Get Started with Remote Debugging Windows 10 Devices - Microsoft Edge Development | Microsoft Docs",
    "type": "page",
    "url": "https://docs.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/remote-debugging/windows",
    "webSocketDebuggerUrl": "ws://172.17.75.195:80/msedge/7264/devtools/page/ED4FFDB4529723A0FAFCBDB9B45851BB"
}, ...  ]

/msedge/[pid]/json/version/msedge/[pid]/json/version

提供有关与提供的Microsoft Edge版本匹配的应用程序实例及其支持的 [pid] DevTools 协议版本的信息。Provides information about the Microsoft Edge instance that matches the provided [pid] and which version of the DevTools Protocol it supports.

参数Parameters

None

Return 对象Return object

{
    "Browser": "Edg/82.0.452.0",
    "Protocol-Version": "1.3",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/82.0.4080.0 Safari/537.36 Edg/82.0.452.0",
    "V8-Version": "8.2.263",
    "WebKit-Version": "537.36 (@fe0232051787ca94ac8edfc0084c3488b7d9bdb2)",
    "webSocketDebuggerUrl": "172.17.75.195:80/msedge/7264/devtools/browser/7a67c8c4-138b-48e3-bfe0-cb7af34d559a"
}

/msedge/[pid]/json/protocol//msedge/[pid]/json/protocol/

提供序列化为 JSON 的整个协议 API 图面,Microsoft Edge [pid] 提供的实例。Provides the entire protocol API surface serialized as JSON for the Microsoft Edge instance that matches the provided [pid].

参数Parameters

None

Return 对象Return object

JSON 对象,该对象表示与所提供的实例Microsoft Edge使用的协议版本的 [pid] 可用 API 图面。JSON object which represents the available API surface for the version of the protocol that the Microsoft Edge instance that matches the provided [pid] is using.