tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ca92e249b8092343d48eab1ba37aa1275743b42f
parent 0551b4f5b9bcc73b81c641f80e9a5b46295eee82
Author: Jan-Niklas Jaeschke <jjaschke@mozilla.com>
Date:   Wed,  1 Oct 2025 08:36:28 +0000

Bug 1991847 - Navigation API: Rename log module to "NavigationAPI". r=farre

Differential Revision: https://phabricator.services.mozilla.com/D266967

Diffstat:
Mdocshell/base/BrowsingContext.cpp | 4++--
Mdocshell/base/CanonicalBrowsingContext.cpp | 21+++++++++++----------
Mdocshell/base/nsDocShell.cpp | 8++++----
Mdocshell/shistory/nsSHistory.cpp | 2+-
Mdom/events/NavigateEvent.cpp | 4++--
Mdom/navigation/Navigation.cpp | 47++++++++++++++++++++++++-----------------------
Mdom/navigation/NavigationHistoryEntry.cpp | 2+-
7 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp @@ -98,7 +98,7 @@ #include "GVAutoplayRequestStatusIPC.h" extern mozilla::LazyLogModule gAutoplayPermissionLog; -extern mozilla::LazyLogModule gNavigationLog; +extern mozilla::LazyLogModule gNavigationAPILog; extern mozilla::LazyLogModule gTimeoutDeferralLog; #define AUTOPLAY_LOG(msg, ...) \ @@ -2438,7 +2438,7 @@ void BrowsingContext::Navigate(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv, NavigationHistoryBehavior aHistoryHandling, bool aShouldNotForceReplaceInOnLoad) { - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, "Navigate to {} as {}", *aURI, + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Navigate to {} as {}", *aURI, aHistoryHandling); CallerType callerType = aSubjectPrincipal.IsSystemPrincipal() ? CallerType::System diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp @@ -69,7 +69,7 @@ using namespace mozilla::ipc; extern mozilla::LazyLogModule gAutoplayPermissionLog; -extern mozilla::LazyLogModule gNavigationLog; +extern mozilla::LazyLogModule gNavigationAPILog; extern mozilla::LazyLogModule gSHLog; extern mozilla::LazyLogModule gSHIPBFCacheLog; @@ -639,13 +639,13 @@ CanonicalBrowsingContext::CreateLoadingSessionHistoryEntryForLoad( bool sessionHistoryLoad = existingLoadingInfo && existingLoadingInfo->mLoadIsFromSessionHistory; - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Determining navigation type from loadType={}", aLoadState->LoadType()); Maybe<NavigationType> navigationType = NavigationUtils::NavigationTypeFromLoadType(aLoadState->LoadType()); if (!navigationType) { - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Failed to determine navigation type"); return loadingInfo; } @@ -705,14 +705,14 @@ CanonicalBrowsingContext::CreateLoadingSessionHistoryEntryForLoad( loadingInfo->mContiguousEntries.AppendElement(entry->Info()); } - if (MOZ_LOG_TEST(gNavigationLog, LogLevel::Debug)) { + if (MOZ_LOG_TEST(gNavigationAPILog, LogLevel::Debug)) { int32_t index = 0; - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Preparing contiguous for {} ({}load))", entry->Info().GetURI()->GetSpecOrDefault(), sessionHistoryLoad ? "history " : ""); for (const auto& entry : loadingInfo->mContiguousEntries) { - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "{}+- {} SHI {} {}\n URL = {}", (mActiveEntry && entry == mActiveEntry->Info()) ? ">" : " ", index++, entry.NavigationKey().ToString().get(), @@ -723,13 +723,14 @@ CanonicalBrowsingContext::CreateLoadingSessionHistoryEntryForLoad( loadingInfo->mTriggeringEntry = mActiveEntry ? Some(mActiveEntry->Info()) : Nothing(); - MOZ_LOG_FMT(gNavigationLog, LogLevel::Verbose, "Triggering entry was {}.", + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Verbose, + "Triggering entry was {}.", fmt::ptr(loadingInfo->mTriggeringEntry .map([](auto& entry) { return &entry; }) .valueOr(nullptr))); loadingInfo->mTriggeringNavigationType = navigationType; - MOZ_LOG_FMT(gNavigationLog, LogLevel::Verbose, + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Verbose, "Triggering navigation type was {}.", *navigationType); [[maybe_unused]] auto pred = [&](auto& entry) { @@ -1625,7 +1626,7 @@ void CanonicalBrowsingContext::NavigationTraverse( const nsID& aKey, uint64_t aHistoryEpoch, bool aUserActivation, bool aCheckForCancelation, Maybe<ContentParentId> aContentId, std::function<void(nsresult)>&& aResolver) { - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, "Traverse navigation to {}", + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Traverse navigation to {}", aKey.ToString().get()); nsSHistory* shistory = static_cast<nsSHistory*>(GetSessionHistory()); if (!shistory) { @@ -1669,7 +1670,7 @@ void CanonicalBrowsingContext::NavigationTraverse( } int32_t offset = *targetIndex - *activeIndex; - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, "Performing traversal by {}", + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Performing traversal by {}", offset); HistoryGo(offset, aHistoryEpoch, false, aUserActivation, aCheckForCancelation, diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp @@ -289,7 +289,7 @@ static mozilla::LazyLogModule gDocShellAndDOMWindowLeakLogging( #endif static mozilla::LazyLogModule gDocShellLeakLog("nsDocShellLeak"); extern mozilla::LazyLogModule gPageCacheLog; -extern mozilla::LazyLogModule gNavigationLog; +extern mozilla::LazyLogModule gNavigationAPILog; mozilla::LazyLogModule gSHLog("SessionHistory"); extern mozilla::LazyLogModule gSHIPBFCacheLog; @@ -9373,7 +9373,7 @@ nsresult nsDocShell::HandleSameDocumentNavigation( // reference to avoid null derefs. See bug 914521. if (win) { if (RefPtr navigation = win->Navigation()) { - MOZ_LOG(gNavigationLog, LogLevel::Debug, + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("nsDocShell %p triggering a navigation event from " "HandleSameDocumentNavigation", this)); @@ -12091,7 +12091,7 @@ nsresult nsDocShell::UpdateURLAndHistory( aDocument->SetStateObject(aData); if (RefPtr navigation = aDocument->GetInnerWindow()->Navigation()) { - MOZ_LOG(gNavigationLog, LogLevel::Debug, + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("nsDocShell %p triggering a navigation event for a same-document " "navigation from UpdateURLAndHistory -> isReplace: %s", this, isReplace ? "true" : "false")); @@ -14317,7 +14317,7 @@ void nsDocShell::MoveLoadingToActiveEntry(bool aExpired, uint32_t aCacheKey, navigation->InitializeHistoryEntries(loadingEntry->mContiguousEntries, mActiveEntry.get()); - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Before creating NavigationActivation, " "triggeringEntry={}, triggeringType={}", fmt::ptr(loadingEntry->mTriggeringEntry diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp @@ -100,7 +100,7 @@ LazyLogModule gSHistoryLog("nsSHistory"); #define LOG(format) MOZ_LOG(gSHistoryLog, mozilla::LogLevel::Debug, format) extern mozilla::LazyLogModule gPageCacheLog; -extern mozilla::LazyLogModule gNavigationLog; +extern mozilla::LazyLogModule gNavigationAPILog; extern mozilla::LazyLogModule gSHIPBFCacheLog; // This macro makes it easier to print a log message which includes a URI's diff --git a/dom/events/NavigateEvent.cpp b/dom/events/NavigateEvent.cpp @@ -16,10 +16,10 @@ #include "nsDocShell.h" #include "nsGlobalWindowInner.h" -extern mozilla::LazyLogModule gNavigationLog; +extern mozilla::LazyLogModule gNavigationAPILog; #define LOG_FMT(format, ...) \ - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, format, ##__VA_ARGS__); + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, format, ##__VA_ARGS__); namespace mozilla::dom { diff --git a/dom/navigation/Navigation.cpp b/dom/navigation/Navigation.cpp @@ -42,10 +42,10 @@ #include "nsNetUtil.h" #include "nsTHashtable.h" -mozilla::LazyLogModule gNavigationLog("Navigation"); +mozilla::LazyLogModule gNavigationAPILog("NavigationAPI"); #define LOG_FMT(format, ...) \ - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, format, ##__VA_ARGS__); + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, format, ##__VA_ARGS__); namespace mozilla::dom { @@ -215,7 +215,7 @@ already_AddRefed<NavigationHistoryEntry> Navigation::GetCurrentEntry() const { return nullptr; } - MOZ_LOG(gNavigationLog, LogLevel::Debug, + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("Current Entry: %d; Amount of Entries: %d", int(*mCurrentEntryIndex), int(mEntries.Length()))); MOZ_ASSERT(*mCurrentEntryIndex < mEntries.Length()); @@ -297,7 +297,7 @@ void Navigation::InitializeHistoryEntries( nsID key = aInitialSHInfo->NavigationKey(); nsID id = aInitialSHInfo->NavigationId(); MOZ_LOG( - gNavigationLog, LogLevel::Debug, + gNavigationAPILog, LogLevel::Debug, ("aInitialSHInfo: %s %s\n", key.ToString().get(), id.ToString().get())); } @@ -309,7 +309,7 @@ void Navigation::UpdateEntriesForSameDocumentNavigation( return; } - MOZ_LOG(gNavigationLog, LogLevel::Debug, + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("Updating entries for same-document navigation")); // Steps 2-7. @@ -317,7 +317,7 @@ void Navigation::UpdateEntriesForSameDocumentNavigation( nsTArray<RefPtr<NavigationHistoryEntry>> disposedEntries; switch (aNavigationType) { case NavigationType::Traverse: - MOZ_LOG(gNavigationLog, LogLevel::Debug, ("Traverse navigation")); + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("Traverse navigation")); mCurrentEntryIndex.reset(); for (auto i = 0ul; i < mEntries.Length(); i++) { if (mEntries[i]->IsSameEntry(aDestinationSHE)) { @@ -329,7 +329,7 @@ void Navigation::UpdateEntriesForSameDocumentNavigation( break; case NavigationType::Push: - MOZ_LOG(gNavigationLog, LogLevel::Debug, ("Push navigation")); + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("Push navigation")); mCurrentEntryIndex = Some(mCurrentEntryIndex ? *mCurrentEntryIndex + 1 : 0); while (*mCurrentEntryIndex < mEntries.Length()) { @@ -340,7 +340,7 @@ void Navigation::UpdateEntriesForSameDocumentNavigation( break; case NavigationType::Replace: - MOZ_LOG(gNavigationLog, LogLevel::Debug, ("Replace navigation")); + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("Replace navigation")); if (!oldCurrentEntry) { MOZ_ASSERT(false, "FIXME"); return; @@ -479,7 +479,7 @@ Navigation::CreateSerializedStateAndMaybeSetEarlyErrorResult( void Navigation::Navigate(JSContext* aCx, const nsAString& aUrl, const NavigationNavigateOptions& aOptions, NavigationResult& aResult) { - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Called navigation.navigate() with url = {}", NS_ConvertUTF16toUTF8(aUrl)); // 4. Let document be this's relevant global object's associated Document. @@ -715,7 +715,7 @@ void Navigation::PerformNavigationTraversal(JSContext* aCx, const nsID& aKey, // https://html.spec.whatwg.org/#dom-navigation-reload void Navigation::Reload(JSContext* aCx, const NavigationReloadOptions& aOptions, NavigationResult& aResult) { - MOZ_LOG(gNavigationLog, LogLevel::Debug, ("Called navigation.reload()")); + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("Called navigation.reload()")); // 1. Let document be this's relevant global object's associated Document. const RefPtr<Document> document = GetAssociatedDocument(); if (!document) { @@ -780,7 +780,7 @@ void Navigation::Reload(JSContext* aCx, const NavigationReloadOptions& aOptions, void Navigation::TraverseTo(JSContext* aCx, const nsAString& aKey, const NavigationOptions& aOptions, NavigationResult& aResult) { - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Called navigation.traverseTo() with key = {}", NS_ConvertUTF16toUTF8(aKey).get()); @@ -817,7 +817,7 @@ void Navigation::TraverseTo(JSContext* aCx, const nsAString& aKey, // https://html.spec.whatwg.org/#dom-navigation-back void Navigation::Back(JSContext* aCx, const NavigationOptions& aOptions, NavigationResult& aResult) { - MOZ_LOG(gNavigationLog, LogLevel::Debug, ("Called navigation.back()")); + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("Called navigation.back()")); // 1. If this's current entry index is −1 or 0, then return an early error // result for an "InvalidStateError" DOMException. if (mCurrentEntryIndex.isNothing() || *mCurrentEntryIndex == 0 || @@ -840,7 +840,7 @@ void Navigation::Back(JSContext* aCx, const NavigationOptions& aOptions, // https://html.spec.whatwg.org/#dom-navigation-forward void Navigation::Forward(JSContext* aCx, const NavigationOptions& aOptions, NavigationResult& aResult) { - MOZ_LOG(gNavigationLog, LogLevel::Debug, ("Called navigation.forward()")); + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("Called navigation.forward()")); // 1. If this's current entry index is −1 or is equal to this's entry list's // size − 1, then return an early error result for an "InvalidStateError" @@ -869,7 +869,7 @@ namespace { void LogEntry(NavigationHistoryEntry* aEntry, uint64_t aIndex, uint64_t aTotal, bool aIsCurrent) { if (!aEntry) { - MOZ_LOG(gNavigationLog, LogLevel::Debug, + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, (" +- %d NHEntry null\n", int(aIndex))); return; } @@ -877,14 +877,14 @@ void LogEntry(NavigationHistoryEntry* aEntry, uint64_t aIndex, uint64_t aTotal, nsString key, id; aEntry->GetKey(key); aEntry->GetId(id); - MOZ_LOG(gNavigationLog, LogLevel::Debug, + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("%s+- %d NHEntry %p %s %s\n", aIsCurrent ? ">" : " ", int(aIndex), aEntry, NS_ConvertUTF16toUTF8(key).get(), NS_ConvertUTF16toUTF8(id).get())); nsAutoString url; aEntry->GetUrl(url); - MOZ_LOG(gNavigationLog, LogLevel::Debug, + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, (" URL = %s\n", NS_ConvertUTF16toUTF8(url).get())); } @@ -1052,7 +1052,7 @@ static bool HasIdenticalFragment(nsIURI* aURI, nsIURI* aOtherURI) { static void LogEvent(Event* aEvent, NavigateEvent* aOngoingEvent, const nsACString& aReason) { - if (!MOZ_LOG_TEST(gNavigationLog, LogLevel::Debug)) { + if (!MOZ_LOG_TEST(gNavigationAPILog, LogLevel::Debug)) { return; } @@ -1761,11 +1761,11 @@ void Navigation::UpdateNeedsTraverse() { } void Navigation::LogHistory() const { - if (!MOZ_LOG_TEST(gNavigationLog, LogLevel::Debug)) { + if (!MOZ_LOG_TEST(gNavigationAPILog, LogLevel::Debug)) { return; } - MOZ_LOG(gNavigationLog, LogLevel::Debug, + MOZ_LOG(gNavigationAPILog, LogLevel::Debug, ("Navigation %p (current entry index: %d)\n", this, mCurrentEntryIndex ? int(*mCurrentEntryIndex) : -1)); auto length = mEntries.Length(); @@ -1850,7 +1850,7 @@ void Navigation::CreateNavigationActivationFrom( NavigationType aNavigationType) { // Note: we do Step 7.1 at the end of method so we can both create and // initialize the activation at once. - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, "Creating NavigationActivation for from={}, type={}", fmt::ptr(aPreviousEntryForActivation), aNavigationType); RefPtr currentEntry = GetCurrentEntry(); @@ -1870,7 +1870,8 @@ void Navigation::CreateNavigationActivationFrom( // to navigation's entry list[previousEntryIndex]. RefPtr<NavigationHistoryEntry> oldEntry; if (possiblePreviousEntry != mEntries.end()) { - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, "Found previous entry at {}", + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, + "Found previous entry at {}", fmt::ptr(possiblePreviousEntry->get())); oldEntry = *possiblePreviousEntry; } else if (aNavigationType == NavigationType::Replace && @@ -1892,8 +1893,8 @@ void Navigation::CreateNavigationActivationFrom( currentURI, previousURI, false, false))) { oldEntry = MakeRefPtr<NavigationHistoryEntry>( GetOwnerGlobal(), aPreviousEntryForActivation, -1); - MOZ_LOG_FMT(gNavigationLog, LogLevel::Debug, "Created a new entry at {}", - fmt::ptr(oldEntry.get())); + MOZ_LOG_FMT(gNavigationAPILog, LogLevel::Debug, + "Created a new entry at {}", fmt::ptr(oldEntry.get())); } } diff --git a/dom/navigation/NavigationHistoryEntry.cpp b/dom/navigation/NavigationHistoryEntry.cpp @@ -12,7 +12,7 @@ #include "nsDocShell.h" #include "nsGlobalWindowInner.h" -extern mozilla::LazyLogModule gNavigationLog; +extern mozilla::LazyLogModule gNavigationAPILog; namespace mozilla::dom {