Bug 1948254 - Part 4: Implement #navigate-event-firing. r=webidl,smaug,jjaschke

This includes:

* #fire-a-traverse-navigate-event
* #fire-a-push/replace/reload-navigate-event
* #fire-a-download-request-navigate-event

which are all implemented in terms of #inner-navigate-event-firing-algorithm.

Actually calling any of the above is only added for History.pushState and
History.replaceState using #fire-a-push/replace/reload-navigate-event.

Differential Revision: https://phabricator.services.mozilla.com/D238786
This commit is contained in:
Andreas Farre
2025-03-18 16:24:26 +00:00
parent a9a50fd039
commit a3594f5aec
22 changed files with 1182 additions and 42 deletions

View File

@@ -11353,6 +11353,20 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
} // end of same-origin check
// https://html.spec.whatwg.org/#shared-history-push/replace-state-steps
// Step 8
if (nsCOMPtr<nsPIDOMWindowInner> window = document->GetInnerWindow()) {
if (RefPtr<Navigation> navigation = window->Navigation();
navigation &&
navigation->FirePushReplaceReloadNavigateEvent(
aReplace ? NavigationType::Replace : NavigationType::Push, newURI,
/* aIsSameDocument */ true, /* aUserInvolvement */ Nothing(),
/* aSourceElement */ nullptr, /* aFormDataEntryList */ Nothing(),
/* aNavigationAPIState */ nullptr, scContainer)) {
return NS_OK;
}
}
// Step 8: call "URL and history update steps"
rv = UpdateURLAndHistory(document, newURI, scContainer,
aReplace ? NavigationHistoryBehavior::Replace
@@ -13647,6 +13661,11 @@ bool nsDocShell::GetIsAttemptingToNavigate() {
return mCheckingSessionHistory;
}
mozilla::dom::SessionHistoryInfo* nsDocShell::GetActiveSessionHistoryInfo()
const {
return mActiveEntry.get();
}
void nsDocShell::SetLoadingSessionHistoryInfo(
const mozilla::dom::LoadingSessionHistoryInfo& aLoadingInfo,
bool aNeedToReportActiveAfterLoadingBecomesActive) {