Bug 1653417 Part 1: Define a pref for specialized video layers on macOS. r=gfx-review...
[gecko.git] / remote / cdp / targets / MainProcessTarget.jsm
blob30ad1974b040b6ca9b352462d32525901048d8d8
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 var EXPORTED_SYMBOLS = ["MainProcessTarget"];
9 const { XPCOMUtils } = ChromeUtils.import(
10   "resource://gre/modules/XPCOMUtils.jsm"
13 XPCOMUtils.defineLazyModuleGetters(this, {
14   MainProcessSession:
15     "chrome://remote/content/cdp/sessions/MainProcessSession.jsm",
16   RemoteAgent: "chrome://remote/content/components/RemoteAgent.jsm",
17   Target: "chrome://remote/content/cdp/targets/Target.jsm",
18 });
20 /**
21  * The main process Target.
22  *
23  * Matches BrowserDevToolsAgentHost from chromium, and only support a couple of Domains:
24  * https://cs.chromium.org/chromium/src/content/browser/devtools/browser_devtools_agent_host.cc?dr=CSs&g=0&l=80-91
25  */
26 class MainProcessTarget extends Target {
27   /*
28    * @param TargetList targetList
29    */
30   constructor(targetList) {
31     super(targetList, MainProcessSession);
33     this.type = "browser";
35     // Define the HTTP path to query this target
36     this.path = `/devtools/browser/${this.id}`;
37   }
39   get wsDebuggerURL() {
40     const { host, port } = RemoteAgent;
41     return `ws://${host}:${port}${this.path}`;
42   }
44   toString() {
45     return `[object MainProcessTarget]`;
46   }
48   toJSON() {
49     return {
50       description: "Main process target",
51       devtoolsFrontendUrl: "",
52       faviconUrl: "",
53       id: this.id,
54       title: "Main process target",
55       type: this.type,
56       url: "",
57       webSocketDebuggerUrl: this.wsDebuggerURL,
58     };
59   }