mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 13:57:32 +00:00
Bug 1720070 - [remote] Avoid calling CDP::start/stop when unnecessary r=webdriver-reviewers,whimboo a=pascalc
It seems that lazy loading RecommendedPreferences.jsm too late still triggers an error if invoked in CDP::stop This doesn't relate to a specific code in RecommendedPreferences as even an empty module still triggers the problem. Therefore it seems mandatory to ensure we don't call stop in CDP.jsm (or WebDriverBiDi.jsm, when implementation will be added there) unless start() was previously called. Differential Revision: https://phabricator.services.mozilla.com/D119968
This commit is contained in:
parent
2e48ec15e6
commit
60e025ee2c
@ -50,6 +50,7 @@ class CDP {
|
||||
constructor(agent) {
|
||||
this.agent = agent;
|
||||
this.targetList = null;
|
||||
this._running = false;
|
||||
}
|
||||
|
||||
get address() {
|
||||
@ -61,6 +62,15 @@ class CDP {
|
||||
* Starts the CDP support.
|
||||
*/
|
||||
async start() {
|
||||
if (this._running) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Note: Ideally this would only be set at the end of the method. However
|
||||
// since start() is async, we prefer to set the flag early in order to
|
||||
// avoid potential race conditions.
|
||||
this._running = true;
|
||||
|
||||
RecommendedPreferences.applyPreferences(RECOMMENDED_PREFS);
|
||||
|
||||
this.agent.server.registerPrefixHandler("/json/", new JSONHandler(this));
|
||||
@ -75,9 +85,6 @@ class CDP {
|
||||
|
||||
await this.targetList.watchForTargets();
|
||||
|
||||
// Immediatly instantiate the main process target in order
|
||||
// to be accessible via HTTP endpoint on startup
|
||||
|
||||
Services.obs.notifyObservers(
|
||||
null,
|
||||
"remote-listening",
|
||||
@ -89,9 +96,17 @@ class CDP {
|
||||
* Stops the CDP support.
|
||||
*/
|
||||
stop() {
|
||||
this.targetList?.destructor();
|
||||
this.targetList = null;
|
||||
if (!this._running) {
|
||||
return;
|
||||
}
|
||||
|
||||
RecommendedPreferences.restorePreferences(RECOMMENDED_PREFS);
|
||||
try {
|
||||
this.targetList?.destructor();
|
||||
this.targetList = null;
|
||||
|
||||
RecommendedPreferences.restorePreferences(RECOMMENDED_PREFS);
|
||||
} finally {
|
||||
this._running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ class WebDriverBiDi {
|
||||
*/
|
||||
constructor(agent) {
|
||||
this.agent = agent;
|
||||
this._running = false;
|
||||
}
|
||||
|
||||
get address() {
|
||||
@ -38,6 +39,12 @@ class WebDriverBiDi {
|
||||
* Starts the WebDriver BiDi support.
|
||||
*/
|
||||
start() {
|
||||
if (this._running) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._running = true;
|
||||
|
||||
Services.obs.notifyObservers(
|
||||
null,
|
||||
"remote-listening",
|
||||
@ -48,5 +55,11 @@ class WebDriverBiDi {
|
||||
/**
|
||||
* Stops the WebDriver BiDi support.
|
||||
*/
|
||||
stop() {}
|
||||
stop() {
|
||||
if (!this._running) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._running = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user