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

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-14 16:12:48 +00:00
parent 6249dabd29
commit a6acda2ef3
20 changed files with 1167 additions and 41 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