tor-browser

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

commit f0a3aabdfa6d9574427c7892a4fa5ab6f2f30d66
parent 10d026cad749d45e315a12960b7c423fa04c564e
Author: Jan-Niklas Jaeschke <jjaschke@mozilla.com>
Date:   Mon, 20 Oct 2025 16:02:47 +0000

Bug 1995331 - Navigation API: Don't report errors when checking whether URL can be rewritten. r=farre

Otherwise, navigations could report security errors into the console which aren't actually errors.

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

Diffstat:
Mdom/base/Document.cpp | 6+++---
Mdom/base/Document.h | 2+-
Mdom/navigation/Navigation.cpp | 3++-
3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp @@ -13505,7 +13505,7 @@ bool Document::HasBeenScrolledSince( return false; } -bool Document::CanRewriteURL(nsIURI* aTargetURL) const { +bool Document::CanRewriteURL(nsIURI* aTargetURL, bool aReportErrors) const { if (nsContentUtils::URIIsLocalFile(aTargetURL)) { // It's a file:// URI nsCOMPtr<nsIPrincipal> principal = NodePrincipal(); @@ -13524,8 +13524,8 @@ bool Document::CanRewriteURL(nsIURI* aTargetURL) const { // set docBaseURI arbitrarily to any domain. bool isPrivateWin = NodePrincipal()->OriginAttributesRef().IsPrivateBrowsing(); - if (NS_FAILED(secMan->CheckSameOriginURI(mDocumentURI, aTargetURL, true, - isPrivateWin))) { + if (NS_FAILED(secMan->CheckSameOriginURI(mDocumentURI, aTargetURL, + aReportErrors, isPrivateWin))) { return false; } diff --git a/dom/base/Document.h b/dom/base/Document.h @@ -2766,7 +2766,7 @@ class Document : public nsINode, * Return true if the documents current url can be re-written to `aTargetURL`. * This implements https://html.spec.whatwg.org/#can-have-its-url-rewritten. */ - bool CanRewriteURL(nsIURI* aTargetURL) const; + bool CanRewriteURL(nsIURI* aTargetURL, bool aReportErrors = true) const; /** * Return true if this document is fully active as described by spec. diff --git a/dom/navigation/Navigation.cpp b/dom/navigation/Navigation.cpp @@ -1241,7 +1241,8 @@ bool Navigation::InnerFireNavigateEvent( // Step 9 init.mCanIntercept = document && - document->CanRewriteURL(aDestination->GetURL()) && + document->CanRewriteURL(aDestination->GetURL(), + /*aReportErrors*/ false) && (aDestination->SameDocument() || aNavigationType != NavigationType::Traverse);