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,7 +1264,33 @@ class BrowsingContextModule extends Module {
} }
const navigated = listener.start(); const navigated = listener.start();
navigated.finally(async () => {
try {
const navigationId = lazy.registerNavigationId({
contextDetails: { context: webProgress.browsingContext },
});
await startNavigationFn();
await navigated;
if (shouldWaitForNavigationRequest) {
await onNavigationRequestCompleted;
}
let url;
if (wait === WaitCondition.None) {
// If wait condition is None, the navigation resolved before the current
// context has navigated.
url = listener.targetURI.spec;
} else {
url = listener.currentURI.spec;
}
return {
navigation: navigationId,
url,
};
} finally {
if (listener.isStarted) { if (listener.isStarted) {
listener.stop(); listener.stop();
} }
@ -1279,37 +1305,9 @@ class BrowsingContextModule extends Module {
wait === WaitCondition.Complete && wait === WaitCondition.Complete &&
shouldWaitForNavigationRequest shouldWaitForNavigationRequest
) { ) {
// We still need to make sure the navigation request has been received
// before performing the cleanup.
await onNavigationRequestCompleted;
await unsubscribeNavigationListeners(); await unsubscribeNavigationListeners();
} }
});
const navigationId = lazy.registerNavigationId({
contextDetails: { context: webProgress.browsingContext },
});
await startNavigationFn();
await navigated;
if (shouldWaitForNavigationRequest) {
await onNavigationRequestCompleted;
} }
let url;
if (wait === WaitCondition.None) {
// If wait condition is None, the navigation resolved before the current
// context has navigated.
url = listener.targetURI.spec;
} else {
url = listener.currentURI.spec;
}
return {
navigation: navigationId,
url,
};
} }
/** /**