Bug 1690474 - [remote] Move CDP specific code to cdp/. r=remote-protocol-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D104574
This commit is contained in:
Henrik Skupin 2021-02-14 14:24:27 +00:00
Родитель ec7ae63ad0
Коммит 8cb90829cc
59 изменённых файлов: 207 добавлений и 204 удалений

Просмотреть файл

@ -158,7 +158,7 @@ modules/libpref/test/unit/*data/
python/
# These are (mainly) imported code that we don't want to lint to make imports easier.
remote/Protocol.jsm
remote/cdp/Protocol.jsm
remote/test/browser/chrome-remote-interface.js
# services/ exclusions

Просмотреть файл

@ -15,7 +15,7 @@ const { truncate } = ChromeUtils.import(
);
const { Log } = ChromeUtils.import("chrome://remote/content/shared/Log.jsm");
const { UnknownMethodError } = ChromeUtils.import(
"chrome://remote/content/Error.jsm"
"chrome://remote/content/cdp/Error.jsm"
);
XPCOMUtils.defineLazyGetter(this, "log", Log.get);

Просмотреть файл

@ -51,8 +51,8 @@ class RemoteAgentError extends Error {
* The error must be of this form:
*
* {"message": "TypeError: foo is not a function\n
* execute@chrome://remote/content/sessions/Session.jsm:73:39\n
* onMessage@chrome://remote/content/sessions/TabSession.jsm:65:20"}
* execute@chrome://remote/content/cdp/sessions/Session.jsm:73:39\n
* onMessage@chrome://remote/content/cdp/sessions/TabSession.jsm:65:20"}
*
* This approach has the notable deficiency that it cannot deal
* with causes to errors because of the unstructured nature of CDP

Просмотреть файл

@ -12,9 +12,11 @@ const { HTTP_404, HTTP_505 } = ChromeUtils.import(
"chrome://remote/content/server/HTTPD.jsm"
);
const { Log } = ChromeUtils.import("chrome://remote/content/shared/Log.jsm");
const { Protocol } = ChromeUtils.import("chrome://remote/content/Protocol.jsm");
const { Protocol } = ChromeUtils.import(
"chrome://remote/content/cdp/Protocol.jsm"
);
const { RemoteAgentError } = ChromeUtils.import(
"chrome://remote/content/Error.jsm"
"chrome://remote/content/cdp/Error.jsm"
);
class JSONHandler {

Просмотреть файл

Просмотреть файл

@ -20,7 +20,7 @@ XPCOMUtils.defineLazyServiceGetters(this, {
});
const { UnsupportedError } = ChromeUtils.import(
"chrome://remote/content/Error.jsm"
"chrome://remote/content/cdp/Error.jsm"
);
class StreamRegistry {

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["ContentProcessDomain"];
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
class ContentProcessDomain extends Domain {

Просмотреть файл

@ -0,0 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["ContentProcessDomains"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const ContentProcessDomains = {};
XPCOMUtils.defineLazyModuleGetters(ContentProcessDomains, {
DOM: "chrome://remote/content/cdp/domains/content/DOM.jsm",
Emulation: "chrome://remote/content/cdp/domains/content/Emulation.jsm",
Input: "chrome://remote/content/cdp/domains/content/Input.jsm",
Log: "chrome://remote/content/cdp/domains/content/Log.jsm",
Network: "chrome://remote/content/cdp/domains/content/Network.jsm",
Page: "chrome://remote/content/cdp/domains/content/Page.jsm",
Performance: "chrome://remote/content/cdp/domains/content/Performance.jsm",
Runtime: "chrome://remote/content/cdp/domains/content/Runtime.jsm",
Security: "chrome://remote/content/cdp/domains/content/Security.jsm",
});

Просмотреть файл

Просмотреть файл

@ -7,10 +7,10 @@
var EXPORTED_SYMBOLS = ["DomainCache"];
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { UnknownMethodError } = ChromeUtils.import(
"chrome://remote/content/Error.jsm"
"chrome://remote/content/cdp/Error.jsm"
);
/**

Просмотреть файл

@ -0,0 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["ParentProcessDomains"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const ParentProcessDomains = {};
XPCOMUtils.defineLazyModuleGetters(ParentProcessDomains, {
Browser: "chrome://remote/content/cdp/domains/parent/Browser.jsm",
Emulation: "chrome://remote/content/cdp/domains/parent/Emulation.jsm",
Input: "chrome://remote/content/cdp/domains/parent/Input.jsm",
IO: "chrome://remote/content/cdp/domains/parent/IO.jsm",
Network: "chrome://remote/content/cdp/domains/parent/Network.jsm",
Page: "chrome://remote/content/cdp/domains/parent/Page.jsm",
Security: "chrome://remote/content/cdp/domains/parent/Security.jsm",
Target: "chrome://remote/content/cdp/domains/parent/Target.jsm",
});

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["DOM"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/domains/ContentProcessDomain.jsm"
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
class DOM extends ContentProcessDomain {

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["Emulation"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/domains/ContentProcessDomain.jsm"
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
class Emulation extends ContentProcessDomain {

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["Input"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/domains/ContentProcessDomain.jsm"
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
class Input extends ContentProcessDomain {

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["Log"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/domains/ContentProcessDomain.jsm"
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["Network"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/domains/ContentProcessDomain.jsm"
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
class Network extends ContentProcessDomain {

Просмотреть файл

@ -11,7 +11,7 @@ const { XPCOMUtils } = ChromeUtils.import(
);
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/domains/ContentProcessDomain.jsm"
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
XPCOMUtils.defineLazyServiceGetter(

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["Performance"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/domains/ContentProcessDomain.jsm"
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
class Performance extends ContentProcessDomain {

Просмотреть файл

@ -13,10 +13,10 @@ const { addDebuggerToGlobal } = ChromeUtils.import(
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/domains/ContentProcessDomain.jsm"
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const { ExecutionContext } = ChromeUtils.import(
"chrome://remote/content/domains/content/runtime/ExecutionContext.jsm"
"chrome://remote/content/cdp/domains/content/runtime/ExecutionContext.jsm"
);
const { executeSoon } = ChromeUtils.import(
"chrome://remote/content/shared/Sync.jsm"

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["Security"];
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/domains/ContentProcessDomain.jsm"
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
class Security extends ContentProcessDomain {

Просмотреть файл

@ -8,7 +8,7 @@ var EXPORTED_SYMBOLS = ["Browser"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
class Browser extends Domain {

Просмотреть файл

@ -9,7 +9,7 @@ var EXPORTED_SYMBOLS = ["Emulation"];
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const MAX_WINDOW_SIZE = 10000000;

Просмотреть файл

@ -15,10 +15,10 @@ XPCOMUtils.defineLazyModuleGetters(this, {
});
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { StreamRegistry } = ChromeUtils.import(
"chrome://remote/content/StreamRegistry.jsm"
"chrome://remote/content/cdp/StreamRegistry.jsm"
);
const DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024;

Просмотреть файл

@ -9,7 +9,7 @@ var EXPORTED_SYMBOLS = ["Input"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
class Input extends Domain {

Просмотреть файл

@ -15,7 +15,7 @@ const { XPCOMUtils } = ChromeUtils.import(
XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const MAX_COOKIE_EXPIRY = Number.MAX_SAFE_INTEGER;

Просмотреть файл

@ -22,16 +22,16 @@ const { clearInterval, setInterval } = ChromeUtils.import(
);
const { DialogHandler } = ChromeUtils.import(
"chrome://remote/content/domains/parent/page/DialogHandler.jsm"
"chrome://remote/content/cdp/domains/parent/page/DialogHandler.jsm"
);
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { UnsupportedError } = ChromeUtils.import(
"chrome://remote/content/Error.jsm"
"chrome://remote/content/cdp/Error.jsm"
);
const { streamRegistry } = ChromeUtils.import(
"chrome://remote/content/domains/parent/IO.jsm"
"chrome://remote/content/cdp/domains/parent/IO.jsm"
);
const { PollPromise } = ChromeUtils.import(
"chrome://remote/content/shared/Sync.jsm"

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["Security"];
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { Preferences } = ChromeUtils.import(

Просмотреть файл

@ -20,16 +20,16 @@ const { ContextualIdentityService } = ChromeUtils.import(
"resource://gre/modules/ContextualIdentityService.jsm"
);
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { MainProcessTarget } = ChromeUtils.import(
"chrome://remote/content/targets/MainProcessTarget.jsm"
"chrome://remote/content/cdp/targets/MainProcessTarget.jsm"
);
const { TabManager } = ChromeUtils.import(
"chrome://remote/content/shared/TabManager.jsm"
);
const { TabSession } = ChromeUtils.import(
"chrome://remote/content/sessions/TabSession.jsm"
"chrome://remote/content/cdp/sessions/TabSession.jsm"
);
const { WindowManager } = ChromeUtils.import(
"chrome://remote/content/shared/WindowManager.jsm"

Просмотреть файл

@ -16,7 +16,7 @@ const { CommonUtils } = ChromeUtils.import(
"resource://services-common/utils.js"
);
const { ChannelEventSinkFactory } = ChromeUtils.import(
"chrome://remote/content/observers/ChannelEventSink.jsm"
"chrome://remote/content/cdp/observers/ChannelEventSink.jsm"
);
const CC = Components.Constructor;

Просмотреть файл

@ -7,16 +7,16 @@
var EXPORTED_SYMBOLS = ["ContentProcessSession"];
const { ContentProcessDomains } = ChromeUtils.import(
"chrome://remote/content/domains/ContentProcessDomains.jsm"
"chrome://remote/content/cdp/domains/ContentProcessDomains.jsm"
);
const { DomainCache } = ChromeUtils.import(
"chrome://remote/content/domains/DomainCache.jsm"
"chrome://remote/content/cdp/domains/DomainCache.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"ContextObserver",
"chrome://remote/content/observers/ContextObserver.jsm"
"chrome://remote/content/cdp/observers/ContextObserver.jsm"
);
class ContentProcessSession {

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["MainProcessSession"];
const { Session } = ChromeUtils.import(
"chrome://remote/content/sessions/Session.jsm"
"chrome://remote/content/cdp/sessions/Session.jsm"
);
/**

Просмотреть файл

@ -7,14 +7,14 @@
var EXPORTED_SYMBOLS = ["Session"];
const { ParentProcessDomains } = ChromeUtils.import(
"chrome://remote/content/domains/ParentProcessDomains.jsm"
"chrome://remote/content/cdp/domains/ParentProcessDomains.jsm"
);
const { DomainCache } = ChromeUtils.import(
"chrome://remote/content/domains/DomainCache.jsm"
"chrome://remote/content/cdp/domains/DomainCache.jsm"
);
const { NetworkObserver } = ChromeUtils.import(
"chrome://remote/content/observers/NetworkObserver.jsm"
"chrome://remote/content/cdp/observers/NetworkObserver.jsm"
);
/**

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["TabSession"];
const { Session } = ChromeUtils.import(
"chrome://remote/content/sessions/Session.jsm"
"chrome://remote/content/cdp/sessions/Session.jsm"
);
/**
@ -40,7 +40,7 @@ class TabSession extends Session {
this.mm.addMessageListener("remote:error", this);
this.mm.loadFrameScript(
"chrome://remote/content/sessions/frame-script.js",
"chrome://remote/content/cdp/sessions/frame-script.js",
false
);
}

Просмотреть файл

@ -5,7 +5,7 @@
"use strict";
const { ContentProcessSession } = ChromeUtils.import(
"chrome://remote/content/sessions/ContentProcessSession.jsm"
"chrome://remote/content/cdp/sessions/ContentProcessSession.jsm"
);
/* global content, docShell */

Просмотреть файл

@ -7,10 +7,10 @@
var EXPORTED_SYMBOLS = ["MainProcessTarget"];
const { Target } = ChromeUtils.import(
"chrome://remote/content/targets/Target.jsm"
"chrome://remote/content/cdp/targets/Target.jsm"
);
const { MainProcessSession } = ChromeUtils.import(
"chrome://remote/content/sessions/MainProcessSession.jsm"
"chrome://remote/content/cdp/sessions/MainProcessSession.jsm"
);
const { RemoteAgent } = ChromeUtils.import(
"chrome://remote/content/components/RemoteAgent.jsm"

Просмотреть файл

@ -7,11 +7,11 @@
var EXPORTED_SYMBOLS = ["TabTarget"];
const { Target } = ChromeUtils.import(
"chrome://remote/content/targets/Target.jsm"
"chrome://remote/content/cdp/targets/Target.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { TabSession } = ChromeUtils.import(
"chrome://remote/content/sessions/TabSession.jsm"
"chrome://remote/content/cdp/sessions/TabSession.jsm"
);
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"

Просмотреть файл

@ -7,7 +7,7 @@
var EXPORTED_SYMBOLS = ["Target"];
const { Connection } = ChromeUtils.import(
"chrome://remote/content/Connection.jsm"
"chrome://remote/content/cdp/Connection.jsm"
);
const { WebSocketTransport } = ChromeUtils.import(
"chrome://remote/content/server/WebSocketTransport.jsm"

Просмотреть файл

@ -10,13 +10,13 @@ const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
);
const { TabTarget } = ChromeUtils.import(
"chrome://remote/content/targets/TabTarget.jsm"
"chrome://remote/content/cdp/targets/TabTarget.jsm"
);
const { MainProcessTarget } = ChromeUtils.import(
"chrome://remote/content/targets/MainProcessTarget.jsm"
"chrome://remote/content/cdp/targets/MainProcessTarget.jsm"
);
const { TabObserver } = ChromeUtils.import(
"chrome://remote/content/observers/TargetObserver.jsm"
"chrome://remote/content/cdp/observers/TargetObserver.jsm"
);
class TargetList {

Просмотреть файл

@ -13,11 +13,12 @@ const { XPCOMUtils } = ChromeUtils.import(
XPCOMUtils.defineLazyModuleGetters(this, {
HttpServer: "chrome://remote/content/server/HTTPD.jsm",
JSONHandler: "chrome://remote/content/JSONHandler.jsm",
JSONHandler: "chrome://remote/content/cdp/JSONHandler.jsm",
Log: "chrome://remote/content/shared/Log.jsm",
Preferences: "resource://gre/modules/Preferences.jsm",
RecommendedPreferences: "chrome://remote/content/RecommendedPreferences.jsm",
TargetList: "chrome://remote/content/targets/TargetList.jsm",
RecommendedPreferences:
"chrome://remote/content/cdp/RecommendedPreferences.jsm",
TargetList: "chrome://remote/content/cdp/targets/TargetList.jsm",
});
XPCOMUtils.defineLazyGetter(this, "log", Log.get);

Просмотреть файл

@ -17,7 +17,7 @@ To do that this component glue together three main high level components:
This will be used to implement the various http endpoints of CDP.
There is a few static URL implemented by `JSONHandler` and one dynamic URL per target.
* `JSONHandler`
* `cdp/JSONHandler`
This implements the following three static http endpoints:
* /json/version:
Returns information about the runtime as well as the url of the browser target websocket url.
@ -31,19 +31,19 @@ To do that this component glue together three main high level components:
We have a future intention to fix this and report only what Firefox implements.
You can connect to these websocket URL in order to debug things.
* `targets/TargetList`
* `cdp/targets/TargetList`
This component is responsible of maintaining the list of all debuggable targets.
For now it can be either:
* The main browser target
A special target which allows to inspect the browser, but not any particular tab.
This is implemented by `targets/MainProcessTarget` and is instantiated on startup.
This is implemented by `cdp/targets/MainProcessTarget` and is instantiated on startup.
* Tab targets
Each opened tab will have a related `targets/TabTarget` instantiated on their opening,
Each opened tab will have a related `cdp/targets/TabTarget` instantiated on their opening,
or on server startup for already opened ones.
Each target aims at focusing on one particular context. This context is typically running in one
particular environment. This can be a particular process or thread.
In the future, we will most likely support targets for workers and add-ons.
All targets inherit from `targets/Target`.
All targets inherit from `cdp/targets/Target`.
Connecting to Websocket endpoints
---------------------------------
@ -54,7 +54,7 @@ Once a HTTP request happens, `server/HTTPD` will call the `handle` method on the
For static endpoints registered by `JSONHandler`, this will call `JSONHandler:handle` and return a JSON string as http body.
For target's endpoint, it is slightly more complicated as it requires a special handshake to morph the HTTP connection into a WebSocket one.
The WebSocket is then going to be long lived and be used to inspect the target over time.
When a request is made to a target URL, `targets/Target:handle` is called and:
When a request is made to a target URL, `cdp/targets/Target:handle` is called and:
* delegate the complex HTTP to WebSocket handshake operation to `server/WebSocketHandshake:upgrade`
In return we retrieve a WebSocket object.
@ -71,14 +71,14 @@ When a request is made to a target URL, `targets/Target:handle` is called and:
A connection may have more than one session attached to it.
* instantiate the default session
The session is specific to each target kind and all of them inherit from `session/Session`.
For example, tabs targets uses `session/TabSession` and the main browser target uses `session/MainProcessSession`.
Which session class is used is defined by the Target subclass constructor, which pass a session class reference to targets/Target:constructor.
The session is specific to each target kind and all of them inherit from `cdp/session/Session`.
For example, tabs targets uses `cdp/session/TabSession` and the main browser target uses `cdp/session/MainProcessSession`.
Which session class is used is defined by the Target subclass constructor, which pass a session class reference to `cdp/targets/Target:constructor`.
A session is mostly responsible of accommodating the eventual cross process/cross thread aspects of the target.
The code we are currently describing (`targets/Target:handle`) is running in the parent process.
The code we are currently describing (`cdp/targets/Target:handle`) is running in the parent process.
The session class receive CDP commands from the connection and first try to execute the Domain commands in the parent process.
Then, if the target actually runs in some other context, the session tries to forward this command to this other context, which can be a thread or a process.
Typically, the `sessions/TabSession` forward the CDP command to the content process where the tab is running.
Typically, the `cdp/sessions/TabSession` forward the CDP command to the content process where the tab is running.
It also redirects back the command response as well as Domain events from that process back to the parent process in order to
forward them to the connection.
Sessions will be using the `DomainCache` class as a helper to manage a list of Domain implementations in a given context.
@ -89,7 +89,7 @@ Debugging additional Targets
From a given connection you can know about the other potential targets.
You typically do that via `Target.setDiscoverTargets()`, which will emit `Target.targetCreated` events providing a target ID.
You may create a new session for the new target by handing the ID to `Target.attachToTarget()`, which will return a session ID.
"Target" here is a reference to the CDP Domain implemented in `domains/parent/Target.jsm`. That is different from `targets/Target`
"Target" here is a reference to the CDP Domain implemented in `cdp/domains/parent/Target.jsm`. That is different from `cdp/targets/Target`
class which is an implementation detail of the Remote Agent.
Then, there is two ways to communicate with the other targets:
@ -103,7 +103,7 @@ Then, there is two ways to communicate with the other targets:
This client will re-use the same WebSocket connection, but every single CDP packet will contain an additional `sessionId` attribute.
This helps distinguish packets which relate to the original target as well as the multiple additional targets you may attach to.
In both cases, `Target.attachToTarget()` is special as it will spawn `session/TabSession` for the tab you are attaching to.
In both cases, `Target.attachToTarget()` is special as it will spawn `cdp/session/TabSession` for the tab you are attaching to.
This is the codepath creating non-default session. The default session is related to the target you originally connected to,
so that you don't need any ID for this one. When you want to debug more than one target over a single connection
you need additional sessions, which will have a unique ID.
@ -119,11 +119,11 @@ The main and startup code of the Remote agent code runs in the parent process.
The handling of the command line as well as all the HTTP and WebSocket work is all done in the parent process.
The browser target is also all implemented in the parent process.
But when it comes to a tab target, as the tab runs in the content process, we have to run code there as well.
Let's start from the `sessions/TabSession` class, which has already been described.
Let's start from the `cdp/sessions/TabSession` class, which has already been described.
We receive here JSON packets from the WebSocket connection and we are in the parent process.
In this class, we route the messages to the parent process domains first.
If there is no implementation of the domain or the particular method,
we forward the command to a `session/ContentProcessSession` which runs in the tab's content process.
we forward the command to a `cdp/session/ContentProcessSession` which runs in the tab's content process.
These two Session classes will interact with each other in order to forward back the returned value
of the method we just called, as well as piping back any event being sent by a Domain implemented in any
of the two processes.
@ -161,4 +161,4 @@ Organizational chart of all the classes
```
[1] Target is inherited by TabTarget and MainProcessTarget.
[2] Session is inherited by TabSession and MainProcessSession.
[3] Domain is inherited by Log, Page, Browser, Target.... i.e. all domain implementations. From both domains/parent and domains/content folders.
[3] Domain is inherited by Log, Page, Browser, Target.... i.e. all domain implementations. From both cdp/domains/parent and cdp/domains/content folders.

Просмотреть файл

@ -1,25 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["ContentProcessDomains"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const ContentProcessDomains = {};
XPCOMUtils.defineLazyModuleGetters(ContentProcessDomains, {
DOM: "chrome://remote/content/domains/content/DOM.jsm",
Emulation: "chrome://remote/content/domains/content/Emulation.jsm",
Input: "chrome://remote/content/domains/content/Input.jsm",
Log: "chrome://remote/content/domains/content/Log.jsm",
Network: "chrome://remote/content/domains/content/Network.jsm",
Page: "chrome://remote/content/domains/content/Page.jsm",
Performance: "chrome://remote/content/domains/content/Performance.jsm",
Runtime: "chrome://remote/content/domains/content/Runtime.jsm",
Security: "chrome://remote/content/domains/content/Security.jsm",
});

Просмотреть файл

@ -1,24 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["ParentProcessDomains"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const ParentProcessDomains = {};
XPCOMUtils.defineLazyModuleGetters(ParentProcessDomains, {
Browser: "chrome://remote/content/domains/parent/Browser.jsm",
Emulation: "chrome://remote/content/domains/parent/Emulation.jsm",
Input: "chrome://remote/content/domains/parent/Input.jsm",
IO: "chrome://remote/content/domains/parent/IO.jsm",
Network: "chrome://remote/content/domains/parent/Network.jsm",
Page: "chrome://remote/content/domains/parent/Page.jsm",
Security: "chrome://remote/content/domains/parent/Security.jsm",
Target: "chrome://remote/content/domains/parent/Target.jsm",
});

Просмотреть файл

@ -6,59 +6,56 @@ remote.jar:
% content remote %content/
content/components/RemoteAgent.jsm (components/RemoteAgent.jsm)
content/Connection.jsm (Connection.jsm)
content/Error.jsm (Error.jsm)
content/JSONHandler.jsm (JSONHandler.jsm)
content/Protocol.jsm (Protocol.jsm)
content/RecommendedPreferences.jsm (RecommendedPreferences.jsm)
content/StreamRegistry.jsm (StreamRegistry.jsm)
# observers
content/observers/ChannelEventSink.jsm (observers/ChannelEventSink.jsm)
content/observers/ContextObserver.jsm (observers/ContextObserver.jsm)
content/observers/NetworkObserver.jsm (observers/NetworkObserver.jsm)
content/observers/TargetObserver.jsm (observers/TargetObserver.jsm)
# sessions
content/sessions/frame-script.js (sessions/frame-script.js)
content/sessions/ContentProcessSession.jsm (sessions/ContentProcessSession.jsm)
content/sessions/MainProcessSession.jsm (sessions/MainProcessSession.jsm)
content/sessions/Session.jsm (sessions/Session.jsm)
content/sessions/TabSession.jsm (sessions/TabSession.jsm)
# targets
content/targets/MainProcessTarget.jsm (targets/MainProcessTarget.jsm)
content/targets/TabTarget.jsm (targets/TabTarget.jsm)
content/targets/Target.jsm (targets/Target.jsm)
content/targets/TargetList.jsm (targets/TargetList.jsm)
## CDP ##
content/cdp/Connection.jsm (cdp/Connection.jsm)
content/cdp/Error.jsm (cdp/Error.jsm)
content/cdp/JSONHandler.jsm (cdp/JSONHandler.jsm)
content/cdp/Protocol.jsm (cdp/Protocol.jsm)
content/cdp/RecommendedPreferences.jsm (cdp/RecommendedPreferences.jsm)
content/cdp/StreamRegistry.jsm (cdp/StreamRegistry.jsm)
# domains
content/domains/ContentProcessDomain.jsm (domains/ContentProcessDomain.jsm)
content/domains/ContentProcessDomains.jsm (domains/ContentProcessDomains.jsm)
content/domains/Domain.jsm (domains/Domain.jsm)
content/domains/DomainCache.jsm (domains/DomainCache.jsm)
content/domains/ParentProcessDomains.jsm (domains/ParentProcessDomains.jsm)
content/domains/content/DOM.jsm (domains/content/DOM.jsm)
content/domains/content/Emulation.jsm (domains/content/Emulation.jsm)
content/domains/content/Input.jsm (domains/content/Input.jsm)
content/domains/content/Log.jsm (domains/content/Log.jsm)
content/domains/content/Network.jsm (domains/content/Network.jsm)
content/domains/content/Page.jsm (domains/content/Page.jsm)
content/domains/content/Performance.jsm (domains/content/Performance.jsm)
content/domains/content/Runtime.jsm (domains/content/Runtime.jsm)
content/domains/content/runtime/ExecutionContext.jsm (domains/content/runtime/ExecutionContext.jsm)
content/domains/content/Security.jsm (domains/content/Security.jsm)
content/domains/parent/Browser.jsm (domains/parent/Browser.jsm)
content/domains/parent/Emulation.jsm (domains/parent/Emulation.jsm)
content/domains/parent/Input.jsm (domains/parent/Input.jsm)
content/domains/parent/IO.jsm (domains/parent/IO.jsm)
content/domains/parent/Network.jsm (domains/parent/Network.jsm)
content/domains/parent/Page.jsm (domains/parent/Page.jsm)
content/domains/parent/page/DialogHandler.jsm (domains/parent/page/DialogHandler.jsm)
content/domains/parent/Security.jsm (domains/parent/Security.jsm)
content/domains/parent/Target.jsm (domains/parent/Target.jsm)
content/cdp/domains/ContentProcessDomain.jsm (cdp/domains/ContentProcessDomain.jsm)
content/cdp/domains/ContentProcessDomains.jsm (cdp/domains/ContentProcessDomains.jsm)
content/cdp/domains/Domain.jsm (cdp/domains/Domain.jsm)
content/cdp/domains/DomainCache.jsm (cdp/domains/DomainCache.jsm)
content/cdp/domains/ParentProcessDomains.jsm (cdp/domains/ParentProcessDomains.jsm)
content/cdp/domains/content/DOM.jsm (cdp/domains/content/DOM.jsm)
content/cdp/domains/content/Emulation.jsm (cdp/domains/content/Emulation.jsm)
content/cdp/domains/content/Input.jsm (cdp/domains/content/Input.jsm)
content/cdp/domains/content/Log.jsm (cdp/domains/content/Log.jsm)
content/cdp/domains/content/Network.jsm (cdp/domains/content/Network.jsm)
content/cdp/domains/content/Page.jsm (cdp/domains/content/Page.jsm)
content/cdp/domains/content/Performance.jsm (cdp/domains/content/Performance.jsm)
content/cdp/domains/content/Runtime.jsm (cdp/domains/content/Runtime.jsm)
content/cdp/domains/content/runtime/ExecutionContext.jsm (cdp/domains/content/runtime/ExecutionContext.jsm)
content/cdp/domains/content/Security.jsm (cdp/domains/content/Security.jsm)
content/cdp/domains/parent/Browser.jsm (cdp/domains/parent/Browser.jsm)
content/cdp/domains/parent/Emulation.jsm (cdp/domains/parent/Emulation.jsm)
content/cdp/domains/parent/Input.jsm (cdp/domains/parent/Input.jsm)
content/cdp/domains/parent/IO.jsm (cdp/domains/parent/IO.jsm)
content/cdp/domains/parent/Network.jsm (cdp/domains/parent/Network.jsm)
content/cdp/domains/parent/Page.jsm (cdp/domains/parent/Page.jsm)
content/cdp/domains/parent/page/DialogHandler.jsm (cdp/domains/parent/page/DialogHandler.jsm)
content/cdp/domains/parent/Security.jsm (cdp/domains/parent/Security.jsm)
content/cdp/domains/parent/Target.jsm (cdp/domains/parent/Target.jsm)
# observers
content/cdp/observers/ChannelEventSink.jsm (cdp/observers/ChannelEventSink.jsm)
content/cdp/observers/ContextObserver.jsm (cdp/observers/ContextObserver.jsm)
content/cdp/observers/NetworkObserver.jsm (cdp/observers/NetworkObserver.jsm)
content/cdp/observers/TargetObserver.jsm (cdp/observers/TargetObserver.jsm)
# sessions
content/cdp/sessions/frame-script.js (cdp/sessions/frame-script.js)
content/cdp/sessions/ContentProcessSession.jsm (cdp/sessions/ContentProcessSession.jsm)
content/cdp/sessions/MainProcessSession.jsm (cdp/sessions/MainProcessSession.jsm)
content/cdp/sessions/Session.jsm (cdp/sessions/Session.jsm)
content/cdp/sessions/TabSession.jsm (cdp/sessions/TabSession.jsm)
# targets
content/cdp/targets/MainProcessTarget.jsm (cdp/targets/MainProcessTarget.jsm)
content/cdp/targets/TabTarget.jsm (cdp/targets/TabTarget.jsm)
content/cdp/targets/Target.jsm (cdp/targets/Target.jsm)
content/cdp/targets/TargetList.jsm (cdp/targets/TargetList.jsm)
# transport layer
# transport layer (http / websocket)
content/server/HTTPD.jsm (../netwerk/test/httpserver/httpd.js)
content/server/WebSocketHandshake.jsm (server/WebSocketHandshake.jsm)
content/server/WebSocketTransport.jsm (server/WebSocketTransport.jsm)

Просмотреть файл

@ -9,30 +9,33 @@ DIRS += [
JAR_MANIFESTS += ["jar.mn"]
with Files("cdp/domains/**/Browser.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: Browser")
with Files("cdp/domains/**/DOM.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: DOM")
with Files("cdp/domains/**/Emulation.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: Emulation")
with Files("cdp/domains/**/Input.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: Input")
with Files("cdp/domains/**/Log.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: Log")
with Files("cdp/domains/**/Network.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: Network")
with Files("cdp/domains/**/Page.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: Page")
with Files("cdp/domains/**/Performance.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: Performance")
with Files("cdp/domains/**/Runtime.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: Runtime")
with Files("cdp/domains/**/Security.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: Security")
with Files("cdp/domains/**/Target.jsm"):
BUG_COMPONENT = ("Remote Protocol", "CDP: Target")
with Files("cdp/**"):
BUG_COMPONENT = ("Remote Protocol", "CDP")
with Files("**"):
BUG_COMPONENT = ("Remote Protocol", "Agent")
with Files("domains/**/Emulation.jsm"):
BUG_COMPONENT = ("Remote Protocol", "Emulation")
with Files("domains/**/DOM.jsm"):
BUG_COMPONENT = ("Remote Protocol", "DOM")
with Files("domains/**/Input.jsm"):
BUG_COMPONENT = ("Remote Protocol", "Input")
with Files("domains/**/Log.jsm"):
BUG_COMPONENT = ("Remote Protocol", "Log")
with Files("domains/**/Network.jsm"):
BUG_COMPONENT = ("Remote Protocol", "Network")
with Files("domains/**/Page.jsm"):
BUG_COMPONENT = ("Remote Protocol", "Page")
with Files("domains/**/Performance.jsm"):
BUG_COMPONENT = ("Remote Protocol", "Performance")
with Files("domains/**/Runtime.jsm"):
BUG_COMPONENT = ("Remote Protocol", "Runtime")
with Files("domains/**/Security.jsm"):
BUG_COMPONENT = ("Remote Protocol", "Security")
with Files("domains/**/Browser.jsm"):
BUG_COMPONENT = ("Remote Protocol", "Browser")
with Files("domains/**/Target.jsm"):
BUG_COMPONENT = ("Remote Protocol", "Target")
with Files("doc/**"):
SCHEDULES.exclusive = ["docs"]

Просмотреть файл

@ -9,7 +9,7 @@ const { RemoteAgent } = ChromeUtils.import(
"chrome://remote/content/components/RemoteAgent.jsm"
);
const { RemoteAgentError } = ChromeUtils.import(
"chrome://remote/content/Error.jsm"
"chrome://remote/content/cdp/Error.jsm"
);
const TIMEOUT_MULTIPLIER = SpecialPowers.isDebugBuild ? 4 : 1;

Просмотреть файл

@ -11,7 +11,7 @@ Services.scriptloader.loadSubScript(
);
const { Input: I } = ChromeUtils.import(
"chrome://remote/content/domains/parent/Input.jsm"
"chrome://remote/content/cdp/domains/parent/Input.jsm"
);
const { alt, ctrl, meta, shift } = I.Modifier;

Просмотреть файл

@ -11,7 +11,7 @@ Services.scriptloader.loadSubScript(
);
const { streamRegistry } = ChromeUtils.import(
"chrome://remote/content/domains/parent/IO.jsm"
"chrome://remote/content/cdp/domains/parent/IO.jsm"
);
async function registerFileStream(contents, options = {}) {

Просмотреть файл

@ -4,7 +4,7 @@
"use strict";
const { Connection } = ChromeUtils.import(
"chrome://remote/content/Connection.jsm"
"chrome://remote/content/cdp/Connection.jsm"
);
add_test(function test_Connection_splitMethod() {

Просмотреть файл

@ -4,10 +4,10 @@
"use strict";
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { DomainCache } = ChromeUtils.import(
"chrome://remote/content/domains/DomainCache.jsm"
"chrome://remote/content/cdp/domains/DomainCache.jsm"
);
class MockSession {

Просмотреть файл

@ -8,7 +8,7 @@ const {
RemoteAgentError,
UnknownMethodError,
UnsupportedError,
} = ChromeUtils.import("chrome://remote/content/Error.jsm");
} = ChromeUtils.import("chrome://remote/content/cdp/Error.jsm");
add_test(function test_RemoteAgentError_ctor() {
const e1 = new RemoteAgentError();

Просмотреть файл

@ -4,7 +4,7 @@
"use strict";
const { Session } = ChromeUtils.import(
"chrome://remote/content/sessions/Session.jsm"
"chrome://remote/content/cdp/sessions/Session.jsm"
);
const connection = {

Просмотреть файл

@ -10,7 +10,7 @@ const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { StreamRegistry } = ChromeUtils.import(
"chrome://remote/content/StreamRegistry.jsm"
"chrome://remote/content/cdp/StreamRegistry.jsm"
);
add_test(function test_constructor() {

Просмотреть файл

@ -282,7 +282,7 @@ avoid-blacklist-and-whitelist:
- python/mozbuild/mozbuild/configure/options.py
- python/mozbuild/mozbuild/vendor/moz_yaml.py
- python/mozbuild/mozbuild/vendor/vendor_rust.py
- remote/Protocol.jsm
- remote/cdp/Protocol.jsm
- security/certverifier/NSSCertDBTrustDomain.cpp
- security/certverifier/TrustOverrideUtils.h
- security/manager/ssl/DataStorageList.h