Bug 1852891 - [bidi] Move browsingContext awaitNavigation navigated.finally to try / finally r=webdriver-reviewers,whimboo

Depends on D191609

Differential Revision: https://phabricator.services.mozilla.com/D195440
This commit is contained in:
Julian Descottes 2023-12-05 09:55:13 +00:00
parent 6550258c08
commit 2d15a436fe

View File

@ -1264,28 +1264,8 @@ class BrowsingContextModule extends Module {
}
const navigated = listener.start();
navigated.finally(async () => {
if (listener.isStarted) {
listener.stop();
}
if (wait === WaitCondition.Interactive) {
await this.messageHandler.eventsDispatcher.off(
"browsingContext._documentInteractive",
contextDescriptor,
onDocumentInteractive
);
} else if (
wait === WaitCondition.Complete &&
shouldWaitForNavigationRequest
) {
// We still need to make sure the navigation request has been received
// before performing the cleanup.
await onNavigationRequestCompleted;
await unsubscribeNavigationListeners();
}
});
try {
const navigationId = lazy.registerNavigationId({
contextDetails: { context: webProgress.browsingContext },
});
@ -1310,6 +1290,24 @@ class BrowsingContextModule extends Module {
navigation: navigationId,
url,
};
} finally {
if (listener.isStarted) {
listener.stop();
}
if (wait === WaitCondition.Interactive) {
await this.messageHandler.eventsDispatcher.off(
"browsingContext._documentInteractive",
contextDescriptor,
onDocumentInteractive
);
} else if (
wait === WaitCondition.Complete &&
shouldWaitForNavigationRequest
) {
await unsubscribeNavigationListeners();
}
}
}
/**