Bug 1695031 - Combine build flags --disable-marionette and --enable-cdp as --disable-webdriver. r=firefox-build-system-reviewers,Gijs,smaug,keeler,jdescottes,glandium

Differential Revision: https://phabricator.services.mozilla.com/D115583
This commit is contained in:
Henrik Skupin 2021-05-25 09:13:28 +00:00
Родитель 67f10dbbd4
Коммит fa4fbb78b4
20 изменённых файлов: 148 добавлений и 151 удалений

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

@ -286,18 +286,14 @@ if (AppConstants.MOZ_CRASHREPORTER) {
);
}
if ("@mozilla.org/remote/marionette;1" in Cc) {
if (AppConstants.ENABLE_WEBDRIVER) {
XPCOMUtils.defineLazyServiceGetter(
this,
"Marionette",
"@mozilla.org/remote/marionette;1",
"nsIMarionette"
);
} else {
this.Marionette = { running: false };
}
if (AppConstants.ENABLE_REMOTE_AGENT) {
XPCOMUtils.defineLazyServiceGetter(
this,
"RemoteAgent",
@ -305,6 +301,7 @@ if (AppConstants.ENABLE_REMOTE_AGENT) {
"nsIRemoteAgent"
);
} else {
this.Marionette = { running: false };
this.RemoteAgent = { listening: false };
}

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

@ -318,7 +318,7 @@ if (!isDevtools) {
}
// resource://devtools/shared/worker/loader.js,
// resource://devtools/shared/builtin-modules.js
if (!AppConstants.ENABLE_REMOTE_AGENT) {
if (!AppConstants.ENABLE_WEBDRIVER) {
whitelist.add("resource://gre/modules/jsdebugger.jsm");
}
}

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

@ -2402,15 +2402,6 @@ BrowserGlue.prototype = {
},
},
// request startup of Chromium remote debugging protocol
// (observer will only be notified when --remote-debugging-port is passed)
{
condition: AppConstants.ENABLE_REMOTE_AGENT,
task: () => {
Services.obs.notifyObservers(null, "remote-startup-requested");
},
},
// Run TRR performance measurements for DoH.
{
task: () => {
@ -2510,8 +2501,10 @@ BrowserGlue.prototype = {
},
},
// Marionette needs to be initialized as very last step
// WebDriver components (Remote Agent and Marionette) need to be
// initialized as very last step.
{
condition: AppConstants.ENABLE_WEBDRIVER,
task: () => {
// Use idleDispatch a second time to run this after the per-window
// idle tasks.
@ -2520,11 +2513,15 @@ BrowserGlue.prototype = {
null,
"browser-startup-idle-tasks-finished"
);
// Request startup of the Remote Agent (support for WebDriver BiDi
// and the partial Chrome DevTools protocol) before Marionette.
Services.obs.notifyObservers(null, "remote-startup-requested");
Services.obs.notifyObservers(null, "marionette-startup-requested");
});
},
},
// Do NOT add anything after marionette initialization.
// Do NOT add anything after WebDriver initialization.
];
for (let task of idleTasks) {

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

@ -185,6 +185,6 @@ package-compare::
-diff -u $(DIST)/pack-list.txt $(DIST)/bin-list.txt
rm -f $(DIST)/pack-list.txt $(DIST)/bin-list.txt
ifdef ENABLE_MARIONETTE
DEFINES += -DENABLE_MARIONETTE=1
ifdef ENABLE_WEBDRIVER
DEFINES += -DENABLE_WEBDRIVER=1
endif

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

@ -201,18 +201,14 @@
@RESPATH@/components/l10n-registry.manifest
@RESPATH@/browser/components/l10n-registry.manifest
; CDP remote agent
#ifdef ENABLE_REMOTE_AGENT
@RESPATH@/chrome/remote@JAREXT@
@RESPATH@/chrome/remote.manifest
#endif
; Marionette remote control protocol
#ifdef ENABLE_MARIONETTE
; WebDriver (Marionette, Remote Agent) remote protocols
#ifdef ENABLE_WEBDRIVER
@RESPATH@/chrome/marionette@JAREXT@
@RESPATH@/chrome/marionette.manifest
@RESPATH@/components/marionette.manifest
@RESPATH@/components/marionette.js
@RESPATH@/chrome/remote@JAREXT@
@RESPATH@/chrome/remote.manifest
#endif
#if defined(ENABLE_TESTS) && defined(MOZ_DEBUG)

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

@ -70,8 +70,9 @@
#include "nsICookieManager.h"
#include "nsICookieService.h"
#include "nsIHttpChannel.h"
#ifdef ENABLE_MARIONETTE
#ifdef ENABLE_WEBDRIVER
# include "nsIMarionette.h"
# include "nsIRemoteAgent.h"
#endif
#include "nsStreamUtils.h"
#include "WidgetUtils.h"
@ -2134,16 +2135,27 @@ webgpu::Instance* Navigator::Gpu() {
/* static */
bool Navigator::Webdriver() {
bool marionetteRunning = false;
#ifdef ENABLE_MARIONETTE
#ifdef ENABLE_WEBDRIVER
nsCOMPtr<nsIMarionette> marionette = do_GetService(NS_MARIONETTE_CONTRACTID);
if (marionette) {
bool marionetteRunning = false;
marionette->GetRunning(&marionetteRunning);
if (marionetteRunning) {
return true;
}
}
nsCOMPtr<nsIRemoteAgent> agent = do_GetService(NS_REMOTEAGENT_CONTRACTID);
if (agent) {
bool remoteAgentListening = false;
agent->GetListening(&remoteAgentListening);
if (remoteAgentListening) {
return true;
}
}
#endif
return marionetteRunning;
return false;
}
} // namespace mozilla::dom

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

@ -72,12 +72,8 @@ BINPATH = bin
endif
DEFINES += -DBINPATH=$(BINPATH)
ifdef ENABLE_REMOTE_AGENT
DEFINES += -DENABLE_REMOTE_AGENT=1
endif
ifdef ENABLE_MARIONETTE
DEFINES += -DENABLE_MARIONETTE=1
ifdef ENABLE_WEBDRIVER
DEFINES += -DENABLE_WEBDRIVER=1
endif
ifdef MOZ_CLANG_RT_ASAN_LIB_PATH

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

@ -205,18 +205,14 @@
@BINPATH@/components/GeckoView.manifest
; CDP remote agent
#ifdef ENABLE_REMOTE_AGENT
@BINPATH@/chrome/remote@JAREXT@
@BINPATH@/chrome/remote.manifest
#endif
; Remote control protocol
#ifdef ENABLE_MARIONETTE
; WebDriver (Marionette, Remote Agent) remote protocols
#ifdef ENABLE_WEBDRIVER
@BINPATH@/chrome/marionette@JAREXT@
@BINPATH@/chrome/marionette.manifest
@BINPATH@/components/marionette.manifest
@BINPATH@/components/marionette.js
@BINPATH@/chrome/remote@JAREXT@
@BINPATH@/chrome/remote.manifest
#endif
#ifdef PKG_LOCALE_MANIFEST

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

@ -4445,47 +4445,52 @@ pref("services.common.log.logger.tokenserverclient", "Debug");
pref("services.sync.extension-storage.skipPercentageChance", 50);
#endif // MOZ_SERVICES_SYNC
// Marionette is the remote protocol that lets OOP programs communicate with,
// instrument, and control Gecko.
#if defined(ENABLE_WEBDRIVER)
// WebDriver is a remote control interface that enables introspection and
// control of user agents. It provides a platform- and language-neutral wire
// protocol as a way for out-of-process programs to remotely instruct the
// behavior of web browsers.
//
// Gecko's implementation is backed by Marionette (WebDriver HTTP) and the
// Remote Agent (WebDriver BiDi).
// Delay server startup until a modal dialogue has been clicked to allow time
// for user to set breakpoints in the Browser Toolbox.
pref("marionette.debugging.clicktostart", false);
// Delay server startup until a modal dialogue has been clicked to allow time
// for user to set breakpoints in the Browser Toolbox.
pref("marionette.debugging.clicktostart", false);
// Verbosity of Marionette logger repository.
//
// Available levels are, in descending order of severity, "trace", "debug",
// "config", "info", "warn", "error", and "fatal". The value is treated
// case-insensitively.
pref("marionette.log.level", "Info");
// Verbosity of Marionette logger repository.
//
// Available levels are, in descending order of severity, "trace", "debug",
// "config", "info", "warn", "error", and "fatal". The value is treated
// case-insensitively.
pref("marionette.log.level", "Info");
// Certain log messages that are known to be long are truncated. This
// preference causes them to not be truncated.
pref("marionette.log.truncate", true);
// Certain log messages that are known to be long are truncated. This
// preference causes them to not be truncated.
pref("marionette.log.truncate", true);
// Port to start Marionette server on.
pref("marionette.port", 2828);
// Port to start Marionette server on.
pref("marionette.port", 2828);
// Sets recommended automation preferences when Marionette is started.
pref("marionette.prefs.recommended", true);
// Sets recommended automation preferences when Marionette is started.
pref("marionette.prefs.recommended", true);
#if defined(ENABLE_REMOTE_AGENT)
// Limits remote agent to listen on loopback devices,
// e.g. 127.0.0.1, localhost, and ::1.
pref("remote.force-local", true);
// Defines the verbosity of the internal logger.
//
// Available levels are, in descending order of severity, "Trace", "Debug",
// "Config", "Info", "Warn", "Error", and "Fatal". The value is treated
// case-sensitively.
pref("remote.log.level", "Info");
// Certain log messages that are known to be long are truncated. This
// preference causes them to not be truncated.
pref("remote.log.truncate", true);
#endif
// Defines the verbosity of the internal logger.
//
// Available levels are, in descending order of severity, "Trace", "Debug",
// "Config", "Info", "Warn", "Error", and "Fatal". The value is treated
// case-sensitively.
pref("remote.log.level", "Info");
// Certain log messages that are known to be long are truncated. This
// preference causes them to not be truncated.
pref("remote.log.truncate", true);
// Enable the JSON View tool (an inspector for application/json documents).
pref("devtools.jsonview.enabled", true);

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

@ -43,7 +43,6 @@
"DLL_PREFIX": "lib",
"DLL_SUFFIX": ".dylib",
"EARLY_BETA_OR_EARLIER": true,
"ENABLE_REMOTE_AGENT": true,
"HAVE_SHELL_SERVICE": true,
"HAVE_USR_LIB64_DIR": false,
"MENUBAR_CAN_AUTOHIDE": false,
@ -114,7 +113,6 @@
"DLL_PREFIX": "lib",
"DLL_SUFFIX": ".dylib",
"EARLY_BETA_OR_EARLIER": true,
"ENABLE_REMOTE_AGENT": true,
"HAVE_SHELL_SERVICE": true,
"HAVE_USR_LIB64_DIR": false,
"MENUBAR_CAN_AUTOHIDE": false,

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

@ -18,13 +18,13 @@
#include "nsAppDirectoryServiceDefs.h"
#include "nsCRT.h"
#include "nsILineInputStream.h"
#ifdef ENABLE_MARIONETTE
#ifdef ENABLE_WEBDRIVER
# include "nsIMarionette.h"
#endif
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsIOutputStream.h"
#ifdef ENABLE_REMOTE_AGENT
#ifdef ENABLE_WEBDRIVER
# include "nsIRemoteAgent.h"
#endif
#include "nsISafeOutputStream.h"
@ -722,24 +722,27 @@ nsCertOverrideService::IsCertUsedForOverrides(nsIX509Cert* aCert,
}
static bool IsDebugger() {
bool marionetteRunning = false;
bool remoteAgentListening = false;
#ifdef ENABLE_MARIONETTE
#ifdef ENABLE_WEBDRIVER
nsCOMPtr<nsIMarionette> marionette = do_GetService(NS_MARIONETTE_CONTRACTID);
if (marionette) {
bool marionetteRunning = false;
marionette->GetRunning(&marionetteRunning);
if (marionetteRunning) {
return true;
}
}
#endif
#ifdef ENABLE_REMOTE_AGENT
nsCOMPtr<nsIRemoteAgent> agent = do_GetService(NS_REMOTEAGENT_CONTRACTID);
if (agent) {
bool remoteAgentListening = false;
agent->GetListening(&remoteAgentListening);
if (remoteAgentListening) {
return true;
}
}
#endif
return marionetteRunning || remoteAgentListening;
return false;
}
NS_IMETHODIMP

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

@ -1036,7 +1036,7 @@ var snapshotFormatters = {
},
remoteAgent(data) {
if (!AppConstants.ENABLE_REMOTE_AGENT) {
if (!AppConstants.ENABLE_WEBDRIVER) {
return;
}
$("remote-debugging-accepting-connections").textContent = data.listening;

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

@ -777,7 +777,7 @@
<!-- - - - - - - - - - - - - - - - - - - - - -->
#if defined(ENABLE_REMOTE_AGENT)
#if defined(ENABLE_WEBDRIVER)
<h2 class="major-section" data-l10n-id="remote-debugging-title"/>
<table>

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

@ -71,7 +71,7 @@ if CONFIG['LIBFUZZER']:
if CONFIG['MOZ_WEBRTC']:
gkrust_features += ['webrtc']
if CONFIG['ENABLE_REMOTE_AGENT']:
if CONFIG['ENABLE_WEBDRIVER']:
gkrust_features += ['remote_agent']
# We need to tell Glean it is being built with Gecko.

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

@ -397,8 +397,8 @@ this.AppConstants = Object.freeze({
false,
#endif
ENABLE_REMOTE_AGENT:
#ifdef ENABLE_REMOTE_AGENT
ENABLE_WEBDRIVER:
#ifdef ENABLE_WEBDRIVER
true,
#else
false,

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

@ -1009,7 +1009,7 @@ if (AppConstants.MOZ_SANDBOX) {
};
}
if (AppConstants.ENABLE_REMOTE_AGENT) {
if (AppConstants.ENABLE_WEBDRIVER) {
dataProviders.remoteAgent = function remoteAgent(done) {
const { RemoteAgent } = ChromeUtils.import(
"chrome://remote/content/components/RemoteAgent.jsm"

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

@ -1053,62 +1053,61 @@ set_config("FT2_LIBS", ft2_info.libs)
add_old_configure_assignment("FT2_LIBS", ft2_info.libs)
add_old_configure_assignment("FT2_CFLAGS", ft2_info.cflags)
# Remote agent
# (partial implementation of Chromium Remote Debugging Protocol)
# WebDriver (HTTP / BiDi)
# ==============================================================
#
# See https://firefox-source-docs.mozilla.org/remote/ for more.
# The source code lives under ../remote.
@depends(build_project)
def remote_default(build_project):
# enable for Firefox and Thunderbird only
return build_project in ("browser", "comm/mail", "mobile/android")
option("--enable-cdp", default=remote_default, help="{Enable|Disable} remote agent")
@depends("--enable-cdp")
def remote(value):
if value:
return True
set_config("ENABLE_REMOTE_AGENT", remote)
set_define("ENABLE_REMOTE_AGENT", remote)
# WebDriver is a remote control interface that enables introspection and
# control of user agents. It provides a platform- and language-neutral wire
# protocol as a way for out-of-process programs to remotely instruct the
# behavior of web browsers.
#
# The Gecko implementation is backed by Marionette and Remote Agent.
# Both protocols are not really toolkit features, as much as Gecko engine
# features. But they are enabled based on the toolkit, so here it lives.
#
# Marionette remote protocol
# ==============================================================
# -----------------------------------------------------------
#
# Marionette is the Gecko remote protocol used for various remote control,
# automation, and testing purposes throughout Gecko, Firefox, and Fennec.
# Marionette lives in ../testing/marionette.
#
# Marionette is not really a toolkit feature, as much as a Gecko
# engine feature. But it is enabled based on the toolkit, so here it
# lives.
# automation, and testing purposes throughout Gecko-based applications like
# Firefox, Thunderbird, and any mobile browser built upon GeckoView.
#
# It also backs ../testing/geckodriver, which is Mozilla's WebDriver
# implementation.
#
# For more information, see
# https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette.
option("--disable-marionette", help="Disable Marionette remote protocol")
# The source of Marionette lives in ../testing/marionette.
#
# For more information, see:
# https://firefox-source-docs.mozilla.org/testing/marionette/index.html
#
# Remote Agent (WebDriver BiDi / partial CDP)
# -----------------------------------------------------------
#
# The primary purpose is the implementation of the WebDriver BiDi specification.
# But it also complements the existing Firefox Developer Tools Remote Debugging
# Protocol (RDP) by implementing a subset of the Chrome DevTools Protocol (CDP).
#
# The source of Remote Agent lives in ../remote.
#
# For more information, see:
# https://firefox-source-docs.mozilla.org/remote/index.html
@depends("--disable-marionette")
def marionette(value):
if value:
option(
"--disable-webdriver",
help="Disable support for WebDriver remote protocols",
)
@depends("--disable-webdriver")
def webdriver(enabled):
if enabled:
return True
set_config("ENABLE_MARIONETTE", marionette)
set_define("ENABLE_MARIONETTE", marionette)
set_config("ENABLE_WEBDRIVER", webdriver)
set_define("ENABLE_WEBDRIVER", webdriver)
# geckodriver WebDriver implementation
# ==============================================================

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

@ -39,7 +39,14 @@ XPCOMUtils.defineLazyModuleGetters(this, {
WindowsRegistry: "resource://gre/modules/WindowsRegistry.jsm",
});
if (AppConstants.ENABLE_REMOTE_AGENT) {
if (AppConstants.ENABLE_WEBDRIVER) {
XPCOMUtils.defineLazyServiceGetter(
this,
"Marionette",
"@mozilla.org/remote/marionette;1",
"nsIMarionette"
);
XPCOMUtils.defineLazyServiceGetter(
this,
"RemoteAgent",
@ -47,6 +54,7 @@ if (AppConstants.ENABLE_REMOTE_AGENT) {
"nsIRemoteAgent"
);
} else {
this.Marionette = { running: false };
this.RemoteAgent = { listening: false };
}
@ -3654,16 +3662,8 @@ UpdateService.prototype = {
},
get disabledForTesting() {
let marionetteRunning = false;
if ("nsIMarionette" in Ci) {
marionetteRunning = Cc["@mozilla.org/remote/marionette;1"].createInstance(
Ci.nsIMarionette
).running;
}
return (
(Cu.isInAutomation || marionetteRunning || RemoteAgent.listening) &&
(Cu.isInAutomation || Marionette.running || RemoteAgent.listening) &&
Services.prefs.getBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false)
);
},

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

@ -160,11 +160,9 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk':
'/toolkit/system/gnome',
]
if CONFIG['ENABLE_REMOTE_AGENT']:
DIRS += ['/remote']
if CONFIG['ENABLE_MARIONETTE']:
if CONFIG['ENABLE_WEBDRIVER']:
DIRS += [
'/remote',
'/testing/firefox-ui',
'/testing/marionette',
'/toolkit/components/telemetry/tests/marionette',

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

@ -95,7 +95,7 @@ service(
# nsIXULAppInfo.
service("XULRuntime", "nsIXULRuntime", "@mozilla.org/xre/app-info;1")
if buildconfig.substs.get("ENABLE_REMOTE_AGENT"):
if buildconfig.substs.get("ENABLE_WEBDRIVER"):
service("RemoteAgent", "nsIRemoteAgent", "@mozilla.org/remote/agent;1")
# The definition file needs access to the definitions of the particular
@ -133,7 +133,7 @@ CPP_INCLUDES = """
#include "nsIXULRuntime.h"
"""
if buildconfig.substs.get("ENABLE_REMOTE_AGENT"):
if buildconfig.substs.get("ENABLE_WEBDRIVER"):
CPP_INCLUDES += '#include "nsIRemoteAgent.h"'