From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- dom/xhr/XMLHttpRequest.cpp | 23 +++++++++++++++++------ dom/xhr/XMLHttpRequestMainThread.cpp | 17 ++++++++++++----- dom/xhr/XMLHttpRequestWorker.cpp | 8 +++++--- 3 files changed, 34 insertions(+), 14 deletions(-) (limited to 'dom/xhr') diff --git a/dom/xhr/XMLHttpRequest.cpp b/dom/xhr/XMLHttpRequest.cpp index be94267d63..8807c5515a 100644 --- a/dom/xhr/XMLHttpRequest.cpp +++ b/dom/xhr/XMLHttpRequest.cpp @@ -7,7 +7,9 @@ #include "XMLHttpRequest.h" #include "XMLHttpRequestMainThread.h" #include "XMLHttpRequestWorker.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/Logging.h" +#include "mozilla/StaticPrefs_network.h" #include "mozilla/net/CookieJarSettings.h" mozilla::LazyLogModule gXMLHttpRequestLog("XMLHttpRequest"); @@ -21,15 +23,16 @@ already_AddRefed XMLHttpRequest::Constructor( if (NS_IsMainThread()) { nsCOMPtr global = do_QueryInterface(aGlobal.GetAsSupports()); - nsCOMPtr principal = + nsCOMPtr scriptPrincipal = do_QueryInterface(aGlobal.GetAsSupports()); - if (!global || !principal) { + if (!global || !scriptPrincipal) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } nsCOMPtr cookieJarSettings; nsCOMPtr window = do_QueryInterface(global); + nsCOMPtr principal = scriptPrincipal->GetPrincipal(); if (window) { Document* document = window->GetExtantDoc(); if (NS_WARN_IF(!document)) { @@ -40,13 +43,21 @@ already_AddRefed XMLHttpRequest::Constructor( cookieJarSettings = document->CookieJarSettings(); } else { // We are here because this is a sandbox. - cookieJarSettings = - net::CookieJarSettings::Create(principal->GetPrincipal()); + cookieJarSettings = net::CookieJarSettings::Create(principal); } RefPtr req = new XMLHttpRequestMainThread(global); - req->Construct(principal->GetPrincipal(), cookieJarSettings, false); - req->InitParameters(aParams.mMozAnon, aParams.mMozSystem); + req->Construct(principal, cookieJarSettings, false); + + bool isAnon = false; + if (aParams.mMozAnon.WasPassed()) { + isAnon = aParams.mMozAnon.Value(); + } else { + isAnon = + StaticPrefs::network_fetch_systemDefaultsToOmittingCredentials() && + (aParams.mMozSystem || principal->IsSystemPrincipal()); + } + req->InitParameters(isAnon, aParams.mMozSystem); return req.forget(); } diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index ace26f296f..e18800e24a 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -228,12 +228,19 @@ struct DebugWorkerRefs { (((const std::ostringstream&)(std::ostringstream() << stuff)) \ .str()) // NOLINT -# define DEBUG_WORKERREFS \ - DebugWorkerRefs MOZ_UNIQUE_VAR(debugWR__)(*this, __func__) +# if 1 // Disabling because bug 1855699 +# define DEBUG_WORKERREFS void() +# define DEBUG_WORKERREFS1(x) void() +# else -# define DEBUG_WORKERREFS1(x) \ - DebugWorkerRefs MOZ_UNIQUE_VAR(debugWR__)( \ - *this, STREAM_STRING(__func__ << ": " << x)) // NOLINT +# define DEBUG_WORKERREFS \ + DebugWorkerRefs MOZ_UNIQUE_VAR(debugWR__)(*this, __func__) + +# define DEBUG_WORKERREFS1(x) \ + DebugWorkerRefs MOZ_UNIQUE_VAR(debugWR__)( \ + *this, STREAM_STRING(__func__ << ": " << x)) // NOLINT + +# endif #else # define DEBUG_WORKERREFS void() diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp index 7fdfa8fee9..67cba876db 100644 --- a/dom/xhr/XMLHttpRequestWorker.cpp +++ b/dom/xhr/XMLHttpRequestWorker.cpp @@ -1388,10 +1388,12 @@ already_AddRefed XMLHttpRequestWorker::Construct( new XMLHttpRequestWorker(workerPrivate, global); if (workerPrivate->XHRParamsAllowed()) { - if (aParams.mMozSystem) + if (aParams.mMozSystem) { xhr->mMozAnon = true; - else - xhr->mMozAnon = aParams.mMozAnon; + } else { + xhr->mMozAnon = + aParams.mMozAnon.WasPassed() ? aParams.mMozAnon.Value() : false; + } xhr->mMozSystem = aParams.mMozSystem; } -- cgit v1.2.3