commit 90f6b6e09518af53a63514b80485d3e7edc9e517
parent c5d6450304321a12fe3a0d7e254844af5b4765ad
Author: Jan-Niklas Jaeschke <jjaschke@mozilla.com>
Date: Tue, 28 Oct 2025 17:18:25 +0000
Bug 1970123, part 4 - Navigation API: Add `committed` promise to `NavigationTransition`. r=dom-core,smaug,webidl
This patch does not work on its own.
It adds the promise to `NavigationTransition` and creates the promise
in `#inner-navigate-event-firing`, but the promise is not resolved yet.
This happens in the upcoming patches.
Differential Revision: https://phabricator.services.mozilla.com/D270181
Diffstat:
4 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/dom/navigation/Navigation.cpp b/dom/navigation/Navigation.cpp
@@ -1382,12 +1382,15 @@ bool Navigation::InnerFireNavigateEvent(
MOZ_DIAGNOSTIC_ASSERT(fromNHE);
// Step 33.4
- RefPtr<Promise> promise = Promise::CreateInfallible(globalObject);
+ RefPtr<Promise> committedPromise = Promise::CreateInfallible(globalObject);
+ RefPtr<Promise> finishedPromise = Promise::CreateInfallible(globalObject);
mTransition = MakeAndAddRef<NavigationTransition>(
- globalObject, aNavigationType, fromNHE, promise);
+ globalObject, aNavigationType, fromNHE, committedPromise,
+ finishedPromise);
// Step 33.5
- MOZ_ALWAYS_TRUE(promise->SetAnyPromiseIsHandled());
+ MOZ_ALWAYS_TRUE(committedPromise->SetAnyPromiseIsHandled());
+ MOZ_ALWAYS_TRUE(finishedPromise->SetAnyPromiseIsHandled());
switch (aNavigationType) {
case NavigationType::Traverse:
diff --git a/dom/navigation/NavigationTransition.cpp b/dom/navigation/NavigationTransition.cpp
@@ -15,7 +15,7 @@
namespace mozilla::dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(NavigationTransition, mGlobalObject,
- mFrom, mFinished)
+ mFrom, mCommitted, mFinished)
NS_IMPL_CYCLE_COLLECTING_ADDREF(NavigationTransition)
NS_IMPL_CYCLE_COLLECTING_RELEASE(NavigationTransition)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(NavigationTransition)
@@ -26,8 +26,12 @@ NS_INTERFACE_MAP_END
NavigationTransition::NavigationTransition(nsIGlobalObject* aGlobalObject,
enum NavigationType aNavigationType,
NavigationHistoryEntry* aFrom,
+ Promise* aCommitted,
Promise* aFinished)
- : mNavigationType(aNavigationType), mFrom(aFrom), mFinished(aFinished) {}
+ : mNavigationType(aNavigationType),
+ mFrom(aFrom),
+ mCommitted(aCommitted),
+ mFinished(aFinished) {}
// https://html.spec.whatwg.org/#dom-navigationtransition-navigationtype
enum NavigationType NavigationTransition::NavigationType() const {
@@ -37,6 +41,9 @@ enum NavigationType NavigationTransition::NavigationType() const {
// https://html.spec.whatwg.org/#dom-navigationtransition-from
NavigationHistoryEntry* NavigationTransition::From() const { return mFrom; }
+// https://html.spec.whatwg.org/#dom-navigationtransition-committed
+Promise* NavigationTransition::Committed() const { return mCommitted; }
+
// https://html.spec.whatwg.org/#dom-navigationtransition-finished
Promise* NavigationTransition::Finished() const { return mFinished; }
diff --git a/dom/navigation/NavigationTransition.h b/dom/navigation/NavigationTransition.h
@@ -29,10 +29,14 @@ class NavigationTransition final : public nsISupports, public nsWrapperCache {
NavigationTransition(nsIGlobalObject* aGlobalObject,
NavigationType aNavigationType,
- NavigationHistoryEntry* aFrom, Promise* aFinished);
+ NavigationHistoryEntry* aFrom, Promise* aCommitted,
+ Promise* aFinished);
enum NavigationType NavigationType() const;
NavigationHistoryEntry* From() const;
+
+ Promise* Committed() const;
+
Promise* Finished() const;
JSObject* WrapObject(JSContext* aCx,
@@ -50,6 +54,9 @@ class NavigationTransition final : public nsISupports, public nsWrapperCache {
// https://html.spec.whatwg.org/#concept-navigationtransition-from
RefPtr<NavigationHistoryEntry> mFrom;
+ // https://html.spec.whatwg.org/#concept-navigationtransition-committed
+ RefPtr<Promise> mCommitted;
+
// https://html.spec.whatwg.org/#concept-navigationtransition-finished
RefPtr<Promise> mFinished;
};
diff --git a/dom/webidl/NavigationTransition.webidl b/dom/webidl/NavigationTransition.webidl
@@ -11,5 +11,6 @@
interface NavigationTransition {
readonly attribute NavigationType navigationType;
readonly attribute NavigationHistoryEntry from;
+ readonly attribute Promise<undefined> committed;
readonly attribute Promise<undefined> finished;
};