Bug 1355890 - Add remote-active system notification
Adds a new system notification, "remote-active", which fires
when the Marionette remote protocol becomes active.
MozReview-Commit-ID: 3Parr82Ch6I
--- a/testing/marionette/server.js
+++ b/testing/marionette/server.js
@@ -38,16 +38,18 @@ this.server = {};
const PROTOCOL_VERSION = 3;
const ENV_ENABLED = "MOZ_MARIONETTE";
const PREF_CONTENT_LISTENER = "marionette.contentListener";
const PREF_PORT = "marionette.port";
const PREF_RECOMMENDED = "marionette.prefs.recommended";
+const NOTIFY_RUNNING = "remote-active";
+
// Marionette sets preferences recommended for automation when it starts,
// unless |marionette.prefs.recommended| has been set to false.
// Where noted, some prefs should also be set in the profile passed to
// Marionette to prevent them from affecting startup, since some of these
// are checked before Marionette initialises.
const RECOMMENDED_PREFS = new Map([
// Disable automatic downloading of new releases.
@@ -314,16 +316,18 @@ server.TCPListener = class {
* The marionette.port preference will be populated with the value
* of |this.port|.
*/
start () {
if (this.alive) {
return;
}
+ Services.obs.notifyObservers(this, NOTIFY_RUNNING, true);
+
if (Preferences.get(PREF_RECOMMENDED)) {
// set recommended prefs if they are not already user-defined
for (let [k, v] of RECOMMENDED_PREFS) {
if (!Preferences.isSet(k)) {
logger.debug(`Setting recommended pref ${k} to ${v}`);
Preferences.set(k, v);
this.alteredPrefs.add(k);
}
@@ -351,18 +355,20 @@ server.TCPListener = class {
this.socket.close();
this.socket = null;
for (let k of this.alteredPrefs) {
logger.debug(`Resetting recommended pref ${k}`);
Preferences.reset(k);
}
+ this.alteredPrefs.clear();
- this.alteredPrefs.clear();
+ Services.obs.notifyObservers(this, NOTIFY_RUNNING, false);
+
this.alive = false;
}
onSocketAccepted (serverSocket, clientSocket) {
if (!this._acceptConnections) {
logger.warn("New connections are currently not accepted");
return;
}