Skip to content

Commit

Permalink
Bug 1879363 - [wdspec] Use consistent pattern for all event subsripti…
Browse files Browse the repository at this point in the history
…ons in browsingContext module r=webdriver-reviewers,Sasha

Differential Revision: https://phabricator.services.mozilla.com/D201130
  • Loading branch information
juliandescottes committed Feb 9, 2024
1 parent 65d6adf commit f231ce5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions remote/webdriver-bidi/modules/root/browsingContext.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,18 @@ class BrowsingContextModule extends Module {
}
};

#stopListeningToContextEvent(event) {
this.#subscribedEvents.delete(event);

const hasContextEvent =
this.#subscribedEvents.has("browsingContext.contextCreated") ||
this.#subscribedEvents.has("browsingContext.contextDestroyed");

if (!hasContextEvent) {
this.#contextListener.stopListening();
}
}

#stopListeningToNavigationEvent(event) {
this.#subscribedEvents.delete(event);

Expand Down Expand Up @@ -1890,14 +1902,12 @@ class BrowsingContextModule extends Module {
switch (event) {
case "browsingContext.contextCreated":
case "browsingContext.contextDestroyed": {
this.#contextListener.stopListening();
this.#subscribedEvents.delete(event);
this.#stopListeningToContextEvent(event);
break;
}
case "browsingContext.fragmentNavigated":
case "browsingContext.navigationStarted": {
this.#stopListeningToNavigationEvent();
this.#subscribedEvents.delete(event);
this.#stopListeningToNavigationEvent(event);
break;
}
case "browsingContext.userPromptClosed":
Expand Down

0 comments on commit f231ce5

Please sign in to comment.