Backed out 3 changesets (bug 1693805) for causing bc failures in browser_all_files_referenced.js

CLOSED TREE

Backed out changeset 4b6ec8e2cf78 (bug 1693805)
Backed out changeset 0a1b4a96c1cf (bug 1693805)
Backed out changeset 3c883527d366 (bug 1693805)
This commit is contained in:
Alexandru Michis 2021-07-08 21:55:07 +03:00
Родитель 7e08b2baf8
Коммит 8fd90ddcea
9 изменённых файлов: 63 добавлений и 284 удалений

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

@ -44,44 +44,38 @@ class CDP {
/**
* Creates a new instance of the CDP class.
*
* @param {RemoteAgent} agent
* Reference to the Remote Agent instance.
* @param {HttpServer} server
* The HTTP server that handles new connection requests.
*/
constructor(agent) {
this.agent = agent;
this.targetList = null;
}
constructor(server) {
this.server = server;
get address() {
const mainTarget = this.targetList.getMainProcessTarget();
return mainTarget.wsDebuggerURL;
this.server.registerPrefixHandler("/json/", new JSONHandler(this));
this.targetList = new TargetList();
this.targetList.on("target-created", (eventName, target) => {
this.server.registerPathHandler(target.path, target);
});
this.targetList.on("target-destroyed", (eventName, target) => {
this.server.registerPathHandler(target.path, null);
});
RecommendedPreferences.applyPreferences(RECOMMENDED_PREFS);
}
/**
* Starts the CDP support.
*/
async start() {
RecommendedPreferences.applyPreferences(RECOMMENDED_PREFS);
this.agent.server.registerPrefixHandler("/json/", new JSONHandler(this));
this.targetList = new TargetList();
this.targetList.on("target-created", (eventName, target) => {
this.agent.server.registerPathHandler(target.path, target);
});
this.targetList.on("target-destroyed", (eventName, target) => {
this.agent.server.registerPathHandler(target.path, null);
});
await this.targetList.watchForTargets();
// Immediatly instantiate the main process target in order
// to be accessible via HTTP endpoint on startup
const mainTarget = this.targetList.getMainProcessTarget();
Services.obs.notifyObservers(
null,
"remote-listening",
`DevTools listening on ${this.address}`
`DevTools listening on ${mainTarget.wsDebuggerURL}`
);
}
@ -90,8 +84,6 @@ class CDP {
*/
stop() {
this.targetList.destructor();
this.targetList = null;
RecommendedPreferences.restorePreferences(RECOMMENDED_PREFS);
}
}

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

@ -11,50 +11,38 @@ const { XPCOMUtils } = ChromeUtils.import(
);
XPCOMUtils.defineLazyModuleGetters(this, {
Preferences: "resource://gre/modules/Preferences.jsm",
Services: "resource://gre/modules/Services.jsm",
CDP: "chrome://remote/content/cdp/CDP.jsm",
HttpServer: "chrome://remote/content/server/HTTPD.jsm",
Log: "chrome://remote/content/shared/Log.jsm",
WebDriverBiDi: "chrome://remote/content/webdriver-bidi/WebDriverBiDi.jsm",
Preferences: "resource://gre/modules/Preferences.jsm",
});
XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get());
XPCOMUtils.defineLazyGetter(this, "activeProtocols", () => {
const protocols = Services.prefs.getIntPref("remote.active-protocols");
if (protocols < 1 || protocols > 3) {
throw Error(`Invalid remote protocol identifier: ${protocols}`);
}
const PREF_ACTIVE_PROTOCOLS = "remote.active-protocols";
const PREF_FORCE_LOCAL = "remote.force-local";
return protocols;
});
const WEBDRIVER_BIDI_ACTIVE = 0x1;
// const BIDI_ACTIVE = 0x1;
const CDP_ACTIVE = 0x2;
// By default force local connections only
const LOOPBACKS = ["localhost", "127.0.0.1", "[::1]"];
const PREF_FORCE_LOCAL = "remote.force-local";
class RemoteAgentClass {
constructor() {
this.cdp = null;
this.server = null;
if ((activeProtocols & WEBDRIVER_BIDI_ACTIVE) === WEBDRIVER_BIDI_ACTIVE) {
this.webdriverBiDi = new WebDriverBiDi(this);
logger.debug("WebDriver BiDi enabled");
} else {
this.webdriverBiDi = null;
const protocols = Services.prefs.getIntPref(PREF_ACTIVE_PROTOCOLS);
if (protocols < 1 || protocols > 3) {
throw Error(`Invalid remote protocol identifier: ${protocols}`);
}
this.activeProtocols = protocols;
}
if ((activeProtocols & CDP_ACTIVE) === CDP_ACTIVE) {
this.cdp = new CDP(this);
logger.debug("CDP enabled");
} else {
this.cdp = null;
}
get listening() {
return !!this.server && !this.server.isStopped();
}
get debuggerAddress() {
@ -65,26 +53,6 @@ class RemoteAgentClass {
return `${this.host}:${this.port}`;
}
get host() {
// Bug 1675471: When using the nsIRemoteAgent interface the HTTPd server's
// primary identity ("this.server.identity.primaryHost") is lazily set.
return this.server?._host;
}
get listening() {
return !!this.server && !this.server.isStopped();
}
get port() {
// Bug 1675471: When using the nsIRemoteAgent interface the HTTPd server's
// primary identity ("this.server.identity.primaryPort") is lazily set.
return this.server?._port;
}
get scheme() {
return this.server?.identity.primaryScheme;
}
listen(url) {
if (Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
throw Components.Exception(
@ -116,6 +84,10 @@ class RemoteAgentClass {
this.server = new HttpServer();
if ((this.activeProtocols & CDP_ACTIVE) === CDP_ACTIVE) {
this.cdp = new CDP(this.server);
}
return this.asyncListen(host, port);
}
@ -124,7 +96,6 @@ class RemoteAgentClass {
this.server._start(port, host);
await this.cdp?.start();
await this.webdriverBiDi?.start();
} catch (e) {
await this.close();
logger.error(`Unable to start remote agent: ${e.message}`, e);
@ -136,7 +107,6 @@ class RemoteAgentClass {
// Stop the CDP support before stopping the server.
// Otherwise the HTTP server will fail to stop.
this.cdp?.stop();
this.webdriverBiDi?.stop();
if (this.listening) {
return this.server.stop();
@ -145,12 +115,40 @@ class RemoteAgentClass {
// this function must never fail
logger.error("unable to stop listener", e);
} finally {
this.cdp = null;
this.server = null;
}
return Promise.resolve();
}
get scheme() {
if (!this.server) {
return null;
}
return this.server.identity.primaryScheme;
}
get host() {
if (!this.server) {
return null;
}
// Bug 1675471: When using the nsIRemoteAgent interface the HTTPd server's
// primary identity ("this.server.identity.primaryHost") is lazily set.
return this.server._host;
}
get port() {
if (!this.server) {
return null;
}
// Bug 1675471: When using the nsIRemoteAgent interface the HTTPd server's
// primary identity ("this.server.identity.primaryPort") is lazily set.
return this.server._port;
}
// XPCOM
get QueryInterface() {

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

@ -7,7 +7,6 @@ DIRS += [
"components",
"marionette",
"shared",
"webdriver-bidi",
]
JAR_MANIFESTS += ["jar.mn"]

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

@ -41,10 +41,10 @@ XPCOMUtils.defineLazyGetter(this, "prefLogLevel", () => {
/** E10s compatible wrapper for the standard logger from Log.jsm. */
class Log {
static TYPES = {
BIDI: "BiDi",
CDP: "CDP",
MARIONETTE: "Marionette",
REMOTE_AGENT: "RemoteAgent",
WEBDRIVER_BIDI: "WebDriver BiDi",
};
/**

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

@ -440,9 +440,7 @@ class Capabilities extends Map {
[
"moz:debuggerAddress",
// With bug 1715481 fixed always use the Remote Agent instance
RemoteAgent.listening && RemoteAgent.cdp
? remoteAgent.debuggerAddress
: null,
RemoteAgent.cdp ? remoteAgent.debuggerAddress : null,
],
[
"moz:headless",

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

@ -1,52 +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 = ["WebDriverBiDi"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm",
});
/**
* Entry class for the WebDriver BiDi support.
*
* @see https://w3c.github.io/webdriver-bidi
*/
class WebDriverBiDi {
/**
* Creates a new instance of the WebDriverBiDi class.
*
* @param {RemoteAgent} agent
* Reference to the Remote Agent instance.
*/
constructor(agent) {
this.agent = agent;
}
get address() {
return `ws://${this.agent.host}:${this.agent.port}`;
}
/**
* Starts the WebDriver BiDi support.
*/
start() {
Services.obs.notifyObservers(
null,
"remote-listening",
`WebDriver BiDi listening on ${this.address}`
);
}
/**
* Stops the WebDriver BiDi support.
*/
stop() {}
}

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

@ -1,139 +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 = ["WebDriverBiDiConnection"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
error: "chrome://remote/content/shared/webdriver/Errors.jsm",
Log: "chrome://remote/content/shared/Log.jsm",
truncate: "chrome://remote/content/shared/Format.jsm",
WebSocketConnection: "chrome://remote/content/shared/WebSocketConnection.jsm",
});
XPCOMUtils.defineLazyGetter(this, "logger", () =>
Log.get(Log.TYPES.WEBDRIVER_BIDI)
);
class WebDriverBiDiConnection extends WebSocketConnection {
/**
* @param {WebSocket} webSocket
* The WebSocket server connection to wrap.
* @param {HttpServer} httpdConnection
* Reference to the httpd.js's connection needed for clean-up.
*/
constructor(webSocket, httpdConnection) {
super(webSocket, httpdConnection);
// Each connection has only a single WebDriver session.
this.session = null;
}
/**
* Register a new Session to forward the messages to.
*
* @param {Session} session
* The WebDriverSession to register.
*/
registerSession(session) {
if (this.session) {
throw new error.UnknownError("A session has already been set");
}
this.session = session;
}
/**
* Send the JSON-serializable object to the WebDriver BiDi client.
*
* @param {Object} data
* The object to be sent.
*/
send(data) {
const payload = JSON.stringify(data, null, Log.verbose ? "\t" : null);
logger.trace(truncate`${this.constructor.name} ${this.id} <- ${payload}`);
super.send(data);
}
/**
* Send an error back to the WebDriver BiDi client.
*
* @param {Number} id
* Id of the packet which lead to an error.
* @param {Error} err
* Error object with `message` and `stack` attributes.
*/
sendError(id, error) {}
/**
* Send an event coming from a module to the WebDriver BiDi client.
*
* @param {String} method
* The event name. This is composed by a module name, a dot character
* followed by the event name, e.g. `log.entryAdded`.
* @param {Object} params
* A JSON-serializable object, which is the payload of this event.
*/
sendEvent(method, params) {}
/**
* Send the result of a call to a module's method back to the
* WebDriver BiDi client.
*
* @param {Number} id
* The request id being sent by the client to call the module's method.
* @param {Object} result
* A JSON-serializable object, which is the actual result.
*/
sendResult(id, result) {
this.send({ id, result });
}
// Transport hooks
/**
* Called by the `transport` when the connection is closed.
*/
onClosed() {
super.onClosed();
}
/**
* Receive a packet from the WebSocket layer.
*
* This packet is sent by a WebDriver BiDi client and is meant to execute
* a particular method on a given module.
*
* @param Object packet
* JSON-serializable object sent by the client
*/
async onPacket(packet) {
const payload = JSON.stringify(packet, null, Log.verbose ? "\t" : null);
logger.trace(truncate`${this.constructor.name} ${this.id} -> ${payload}`);
const { id, method /* params */ } = packet;
try {
// First check for mandatory field in the packets
if (typeof id == "undefined") {
throw new TypeError("Message missing 'id' field");
}
if (typeof method == "undefined") {
throw new TypeError("Message missing 'method' field");
}
let result = undefined;
this.sendResult(id, result);
} catch (e) {
this.sendError(packet.id, e);
}
}
}

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

@ -1,9 +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/.
remote.jar:
% content remote %content/
content/webdriver-bidi/WebDriverBiDiConnection.jsm (WebDriverBiDiConnection.jsm)
content/webdriver-bidi/WebDriverBiDi.jsm (WebDriverBiDi.jsm)

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

@ -1,8 +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/.
JAR_MANIFESTS += ["jar.mn"]
with Files("**"):
BUG_COMPONENT = ("Remote Protocol", "WebDriver BiDi")