mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 15:26:07 +00:00
Bug 1751844 - [remote] Unify handling of active port file for CDP and Marionette. r=webdriver-reviewers,jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D136866
This commit is contained in:
parent
fc616aec19
commit
174e59f1e4
@ -18,9 +18,8 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
TargetList: "chrome://remote/content/cdp/targets/TargetList.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "textEncoder", () => new TextEncoder());
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "logger", () => Log.get(Log.TYPES.CDP));
|
||||
XPCOMUtils.defineLazyGetter(this, "textEncoder", () => new TextEncoder());
|
||||
|
||||
// Map of CDP-specific preferences that should be set via
|
||||
// RecommendedPreferences.
|
||||
@ -55,7 +54,7 @@ class CDP {
|
||||
this.targetList = null;
|
||||
|
||||
this._running = false;
|
||||
this._devToolsActivePortPath;
|
||||
this._activePortPath;
|
||||
}
|
||||
|
||||
get address() {
|
||||
@ -97,23 +96,15 @@ class CDP {
|
||||
|
||||
Cu.printStderr(`DevTools listening on ${this.address}\n`);
|
||||
|
||||
// Write connection details to DevToolsActivePort file within the profile
|
||||
// Write connection details to DevToolsActivePort file within the profile.
|
||||
const profileDir = await PathUtils.getProfileDir();
|
||||
this._devToolsActivePortPath = PathUtils.join(
|
||||
profileDir,
|
||||
"DevToolsActivePort"
|
||||
);
|
||||
this._activePortPath = PathUtils.join(profileDir, "DevToolsActivePort");
|
||||
|
||||
const data = `${this.agent.port}\n${this.mainTargetPath}`;
|
||||
try {
|
||||
await IOUtils.write(
|
||||
this._devToolsActivePortPath,
|
||||
textEncoder.encode(data)
|
||||
);
|
||||
await IOUtils.write(this._activePortPath, textEncoder.encode(data));
|
||||
} catch (e) {
|
||||
logger.warn(
|
||||
`Failed to create ${this._devToolsActivePortPath} (${e.message})`
|
||||
);
|
||||
logger.warn(`Failed to create ${this._activePortPath} (${e.message})`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,11 +118,9 @@ class CDP {
|
||||
|
||||
try {
|
||||
try {
|
||||
await IOUtils.remove(this._devToolsActivePortPath);
|
||||
await IOUtils.remove(this._activePortPath);
|
||||
} catch (e) {
|
||||
logger.warn(
|
||||
`Failed to remove ${this._devToolsActivePortPath} (${e.message})`
|
||||
);
|
||||
logger.warn(`Failed to remove ${this._activePortPath} (${e.message})`);
|
||||
}
|
||||
|
||||
this.targetList?.destructor();
|
||||
|
@ -70,7 +70,7 @@ const isRemote =
|
||||
class MarionetteParentProcess {
|
||||
constructor() {
|
||||
this.server = null;
|
||||
this._marionetteActivePortPath;
|
||||
this._activePortPath;
|
||||
|
||||
this.classID = Components.ID("{786a1369-dca5-4adc-8486-33d23c88010a}");
|
||||
this.helpInfo = " --marionette Enable remote control server.\n";
|
||||
@ -298,21 +298,13 @@ class MarionetteParentProcess {
|
||||
|
||||
// Write Marionette port to MarionetteActivePort file within the profile.
|
||||
const profileDir = await PathUtils.getProfileDir();
|
||||
this._marionetteActivePortPath = PathUtils.join(
|
||||
profileDir,
|
||||
"MarionetteActivePort"
|
||||
);
|
||||
this._activePortPath = PathUtils.join(profileDir, "MarionetteActivePort");
|
||||
|
||||
const data = `${this.server.port}`;
|
||||
try {
|
||||
await IOUtils.write(
|
||||
this._marionetteActivePortPath,
|
||||
textEncoder.encode(data)
|
||||
);
|
||||
await IOUtils.write(this._activePortPath, textEncoder.encode(data));
|
||||
} catch (e) {
|
||||
logger.warn(
|
||||
`Failed to create ${this._marionetteActivePortPath} (${e.message})`
|
||||
);
|
||||
logger.warn(`Failed to create ${this._activePortPath} (${e.message})`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -324,11 +316,9 @@ class MarionetteParentProcess {
|
||||
logger.debug("Marionette stopped listening");
|
||||
|
||||
try {
|
||||
await IOUtils.remove(this._marionetteActivePortPath);
|
||||
await IOUtils.remove(this._activePortPath);
|
||||
} catch (e) {
|
||||
logger.warn(
|
||||
`Failed to remove ${this._marionetteActivePortPath} (${e.message})`
|
||||
);
|
||||
logger.warn(`Failed to remove ${this._activePortPath} (${e.message})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user