commit 6af07e666ee1f8685d246f59c7ef2c26e56a50c2
parent 25277aecc63305c6a77983c658363a15a4676563
Author: Adam Vandolder <avandolder@mozilla.com>
Date: Wed, 8 Oct 2025 14:54:34 +0000
Bug 1984007 - Resolve promises before event firing to align with updated Navigation API. r=jjaschke,farre,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D262832
Diffstat:
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/dom/navigation/Navigation.cpp b/dom/navigation/Navigation.cpp
@@ -1443,13 +1443,13 @@ bool Navigation::InnerFireNavigateEvent(
event->Finish(true);
// Step 6
- self->FireEvent(u"navigatesuccess"_ns);
-
- // Step 7
if (apiMethodTracker) {
apiMethodTracker->ResolveFinishedPromise();
}
+ // Step 7
+ self->FireEvent(u"navigatesuccess"_ns);
+
// Step 8
if (self->mTransition) {
self->mTransition->Finished()->MaybeResolveWithUndefined();
@@ -1493,21 +1493,21 @@ bool Navigation::InnerFireNavigateEvent(
// Step 5
event->Finish(false);
+ // Step 7
+ if (apiMethodTracker) {
+ apiMethodTracker->RejectFinishedPromise(aRejectionReason);
+ }
+
if (AutoJSAPI jsapi;
!NS_WARN_IF(!jsapi.Init(event->GetParentObject()))) {
// Step 6
RootedDictionary<ErrorEventInit> init(jsapi.cx());
ExtractErrorInformation(jsapi.cx(), aRejectionReason, init);
- // Step 7
+ // Step 8
self->FireErrorEvent(u"navigateerror"_ns, init);
}
- // Step 8
- if (apiMethodTracker) {
- apiMethodTracker->RejectFinishedPromise(aRejectionReason);
- }
-
// Step 9
if (self->mTransition) {
self->mTransition->Finished()->MaybeReject(aRejectionReason);
@@ -1672,13 +1672,13 @@ void Navigation::AbortOngoingNavigation(JSContext* aCx,
ExtractErrorInformation(aCx, error, init);
// Step 10
- FireErrorEvent(u"navigateerror"_ns, init);
-
- // Step 11
if (mOngoingAPIMethodTracker) {
mOngoingAPIMethodTracker->RejectFinishedPromise(error);
}
+ // Step 11
+ FireErrorEvent(u"navigateerror"_ns, init);
+
// Step 12
if (mTransition) {
// Step 12.1