mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1525245 - Stabilize cookiePolicy/cookiePermission for live documents - part 12 - nsICookieSettings for the channel creation, r=ckerschb,asuth,Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D21538 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
cc423cd937
commit
4fabb4a2a8
@ -82,7 +82,8 @@ class EventSourceImpl final : public nsIObserver,
|
||||
NS_DECL_NSIEVENTTARGET_FULL
|
||||
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
|
||||
|
||||
explicit EventSourceImpl(EventSource* aEventSource);
|
||||
EventSourceImpl(EventSource* aEventSource,
|
||||
nsICookieSettings* aCookieSettings);
|
||||
|
||||
enum { CONNECTING = 0U, OPEN = 1U, CLOSED = 2U };
|
||||
|
||||
@ -291,6 +292,8 @@ class EventSourceImpl final : public nsIObserver,
|
||||
uint64_t mInnerWindowID;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsICookieSettings> mCookieSettings;
|
||||
|
||||
// Pointer to the target thread for checking whether we are
|
||||
// on the target thread. This is intentionally a non-owning
|
||||
// pointer in order not to affect the thread destruction
|
||||
@ -316,7 +319,8 @@ NS_IMPL_ISUPPORTS(EventSourceImpl, nsIObserver, nsIStreamListener,
|
||||
nsIInterfaceRequestor, nsISupportsWeakReference,
|
||||
nsIEventTarget, nsIThreadRetargetableStreamListener)
|
||||
|
||||
EventSourceImpl::EventSourceImpl(EventSource* aEventSource)
|
||||
EventSourceImpl::EventSourceImpl(EventSource* aEventSource,
|
||||
nsICookieSettings* aCookieSettings)
|
||||
: mEventSource(aEventSource),
|
||||
mReconnectionTime(0),
|
||||
mStatus(PARSE_STATE_OFF),
|
||||
@ -328,6 +332,7 @@ EventSourceImpl::EventSourceImpl(EventSource* aEventSource)
|
||||
mScriptLine(0),
|
||||
mScriptColumn(0),
|
||||
mInnerWindowID(0),
|
||||
mCookieSettings(aCookieSettings),
|
||||
mTargetThread(NS_GetCurrentThread()) {
|
||||
MOZ_ASSERT(mEventSource);
|
||||
if (!mIsMainThread) {
|
||||
@ -971,6 +976,8 @@ nsresult EventSourceImpl::InitChannelAndRequestEventSource() {
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
// If we have the document, use it
|
||||
if (doc) {
|
||||
MOZ_ASSERT(mCookieSettings == doc->CookieSettings());
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup();
|
||||
rv = NS_NewChannel(getter_AddRefs(channel), mSrc, doc, securityFlags,
|
||||
nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE,
|
||||
@ -982,6 +989,7 @@ nsresult EventSourceImpl::InitChannelAndRequestEventSource() {
|
||||
// otherwise use the principal
|
||||
rv = NS_NewChannel(getter_AddRefs(channel), mSrc, mPrincipal, securityFlags,
|
||||
nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE,
|
||||
mCookieSettings,
|
||||
nullptr, // aPerformanceStorage
|
||||
nullptr, // loadGroup
|
||||
nullptr, // aCallbacks
|
||||
@ -1777,12 +1785,14 @@ EventSourceImpl::CheckListenerChain() {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
EventSource::EventSource(nsPIDOMWindowInner* aOwnerWindow,
|
||||
nsICookieSettings* aCookieSettings,
|
||||
bool aWithCredentials)
|
||||
: DOMEventTargetHelper(aOwnerWindow),
|
||||
mWithCredentials(aWithCredentials),
|
||||
mIsMainThread(true),
|
||||
mKeepingAlive(false) {
|
||||
mImpl = new EventSourceImpl(this);
|
||||
MOZ_ASSERT(aCookieSettings);
|
||||
mImpl = new EventSourceImpl(this, aCookieSettings);
|
||||
}
|
||||
|
||||
EventSource::~EventSource() {}
|
||||
@ -1806,8 +1816,24 @@ already_AddRefed<EventSource> EventSource::Constructor(
|
||||
|
||||
MOZ_ASSERT(!NS_IsMainThread() || ownerWindow);
|
||||
|
||||
RefPtr<EventSource> eventSource =
|
||||
new EventSource(ownerWindow, aEventSourceInitDict.mWithCredentials);
|
||||
nsCOMPtr<nsICookieSettings> cookieSettings;
|
||||
if (ownerWindow) {
|
||||
Document* doc = ownerWindow->GetExtantDoc();
|
||||
if (NS_WARN_IF(!doc)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cookieSettings = doc->CookieSettings();
|
||||
} else {
|
||||
// Worker side.
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
cookieSettings = workerPrivate->CookieSettings();
|
||||
}
|
||||
|
||||
RefPtr<EventSource> eventSource = new EventSource(
|
||||
ownerWindow, cookieSettings, aEventSourceInitDict.mWithCredentials);
|
||||
RefPtr<EventSourceImpl> eventSourceImp = eventSource->mImpl;
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsDeque.h"
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
class nsICookieSettings;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -80,7 +81,8 @@ class EventSource final : public DOMEventTargetHelper {
|
||||
void Close();
|
||||
|
||||
private:
|
||||
EventSource(nsPIDOMWindowInner* aOwnerWindow, bool aWithCredentials);
|
||||
EventSource(nsPIDOMWindowInner* aOwnerWindow,
|
||||
nsICookieSettings* aCookieSettings, bool aWithCredentials);
|
||||
virtual ~EventSource();
|
||||
// prevent bad usage
|
||||
EventSource(const EventSource& x) = delete;
|
||||
|
@ -279,13 +279,14 @@ nsSyncLoader::GetInterface(const nsIID &aIID, void **aResult) {
|
||||
nsresult nsSyncLoadService::LoadDocument(
|
||||
nsIURI *aURI, nsContentPolicyType aContentPolicyType,
|
||||
nsIPrincipal *aLoaderPrincipal, nsSecurityFlags aSecurityFlags,
|
||||
nsILoadGroup *aLoadGroup, bool aForceToXML, ReferrerPolicy aReferrerPolicy,
|
||||
Document **aResult) {
|
||||
nsILoadGroup *aLoadGroup, nsICookieSettings *aCookieSettings,
|
||||
bool aForceToXML, ReferrerPolicy aReferrerPolicy, Document **aResult) {
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsresult rv = NS_NewChannel(getter_AddRefs(channel), aURI, aLoaderPrincipal,
|
||||
aSecurityFlags, aContentPolicyType,
|
||||
nullptr, // PerformanceStorage
|
||||
aLoadGroup);
|
||||
nsresult rv =
|
||||
NS_NewChannel(getter_AddRefs(channel), aURI, aLoaderPrincipal,
|
||||
aSecurityFlags, aContentPolicyType, aCookieSettings,
|
||||
nullptr, // PerformanceStorage
|
||||
aLoadGroup);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!aForceToXML) {
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nscore.h"
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
|
||||
class nsICookieSettings;
|
||||
class nsIInputStream;
|
||||
class nsILoadGroup;
|
||||
class nsIStreamListener;
|
||||
@ -44,13 +45,12 @@ class nsSyncLoadService {
|
||||
* @param referrerPolicy Referrer policy.
|
||||
* @param aResult [out] The document loaded from the URI.
|
||||
*/
|
||||
static nsresult LoadDocument(nsIURI* aURI,
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
nsIPrincipal* aLoaderPrincipal,
|
||||
nsSecurityFlags aSecurityFlags,
|
||||
nsILoadGroup* aLoadGroup, bool aForceToXML,
|
||||
mozilla::net::ReferrerPolicy aReferrerPolicy,
|
||||
mozilla::dom::Document** aResult);
|
||||
static nsresult LoadDocument(
|
||||
nsIURI* aURI, nsContentPolicyType aContentPolicyType,
|
||||
nsIPrincipal* aLoaderPrincipal, nsSecurityFlags aSecurityFlags,
|
||||
nsILoadGroup* aLoadGroup, nsICookieSettings* aCookieSettings,
|
||||
bool aForceToXML, mozilla::net::ReferrerPolicy aReferrerPolicy,
|
||||
mozilla::dom::Document** aResult);
|
||||
|
||||
/**
|
||||
* Read input stream aIn in chunks and deliver synchronously to aListener.
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "mozilla/dom/Response.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
||||
#include "BodyExtractor.h"
|
||||
@ -389,6 +390,7 @@ class MainThreadFetchRunnable : public Runnable {
|
||||
// so pass false as the last argument to FetchDriver().
|
||||
fetch = new FetchDriver(mRequest, principal, loadGroup,
|
||||
workerPrivate->MainThreadEventTarget(),
|
||||
workerPrivate->CookieSettings(),
|
||||
workerPrivate->GetPerformanceStorage(), false);
|
||||
nsAutoCString spec;
|
||||
if (proxy->GetWorkerPrivate()->GetBaseURI()) {
|
||||
@ -462,6 +464,7 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal,
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal);
|
||||
nsCOMPtr<Document> doc;
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
nsCOMPtr<nsICookieSettings> cookieSettings;
|
||||
nsIPrincipal* principal;
|
||||
bool isTrackingFetch = false;
|
||||
if (window) {
|
||||
@ -472,6 +475,7 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal,
|
||||
}
|
||||
principal = doc->NodePrincipal();
|
||||
loadGroup = doc->GetDocumentLoadGroup();
|
||||
cookieSettings = doc->CookieSettings();
|
||||
|
||||
nsAutoCString fileNameString;
|
||||
if (nsJSUtils::GetCallingLocation(cx, fileNameString)) {
|
||||
@ -488,6 +492,8 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal,
|
||||
aRv.Throw(rv);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cookieSettings = mozilla::net::CookieSettings::Create();
|
||||
}
|
||||
|
||||
Telemetry::Accumulate(Telemetry::FETCH_IS_MAINTHREAD, 1);
|
||||
@ -496,7 +502,7 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal,
|
||||
p, observer, signalImpl, request->MozErrors());
|
||||
RefPtr<FetchDriver> fetch = new FetchDriver(
|
||||
r, principal, loadGroup, aGlobal->EventTargetFor(TaskCategory::Other),
|
||||
nullptr, // PerformanceStorage
|
||||
cookieSettings, nullptr, // PerformanceStorage
|
||||
isTrackingFetch);
|
||||
fetch->SetDocument(doc);
|
||||
resolver->SetLoadGroup(loadGroup);
|
||||
|
@ -323,12 +323,14 @@ NS_IMPL_ISUPPORTS(FetchDriver, nsIStreamListener, nsIChannelEventSink,
|
||||
FetchDriver::FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsIEventTarget* aMainThreadEventTarget,
|
||||
nsICookieSettings* aCookieSettings,
|
||||
PerformanceStorage* aPerformanceStorage,
|
||||
bool aIsTrackingFetch)
|
||||
: mPrincipal(aPrincipal),
|
||||
mLoadGroup(aLoadGroup),
|
||||
mRequest(aRequest),
|
||||
mMainThreadEventTarget(aMainThreadEventTarget),
|
||||
mCookieSettings(aCookieSettings),
|
||||
mPerformanceStorage(aPerformanceStorage),
|
||||
mNeedToObserveOnDataAvailable(false),
|
||||
mIsTrackingFetch(aIsTrackingFetch),
|
||||
@ -509,22 +511,24 @@ nsresult FetchDriver::HttpFetch(
|
||||
nsIRequest::LOAD_BACKGROUND | bypassFlag | nsIChannel::LOAD_CLASSIFY_URI;
|
||||
if (mDocument) {
|
||||
MOZ_ASSERT(mDocument->NodePrincipal() == mPrincipal);
|
||||
MOZ_ASSERT(mDocument->CookieSettings() == mCookieSettings);
|
||||
rv = NS_NewChannel(getter_AddRefs(chan), uri, mDocument, secFlags,
|
||||
mRequest->ContentPolicyType(),
|
||||
nullptr, /* aPerformanceStorage */
|
||||
mLoadGroup, nullptr, /* aCallbacks */
|
||||
loadFlags, ios);
|
||||
} else if (mClientInfo.isSome()) {
|
||||
rv = NS_NewChannel(getter_AddRefs(chan), uri, mPrincipal, mClientInfo.ref(),
|
||||
mController, secFlags, mRequest->ContentPolicyType(),
|
||||
mCookieSettings, mPerformanceStorage, mLoadGroup,
|
||||
nullptr, /* aCallbacks */
|
||||
loadFlags, ios);
|
||||
} else {
|
||||
rv =
|
||||
NS_NewChannel(getter_AddRefs(chan), uri, mPrincipal, mClientInfo.ref(),
|
||||
mController, secFlags, mRequest->ContentPolicyType(),
|
||||
NS_NewChannel(getter_AddRefs(chan), uri, mPrincipal, secFlags,
|
||||
mRequest->ContentPolicyType(), mCookieSettings,
|
||||
mPerformanceStorage, mLoadGroup, nullptr, /* aCallbacks */
|
||||
loadFlags, ios);
|
||||
} else {
|
||||
rv = NS_NewChannel(getter_AddRefs(chan), uri, mPrincipal, secFlags,
|
||||
mRequest->ContentPolicyType(), mPerformanceStorage,
|
||||
mLoadGroup, nullptr, /* aCallbacks */
|
||||
loadFlags, ios);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
|
||||
class nsIConsoleReportCollector;
|
||||
class nsICookieSettings;
|
||||
class nsICSPEventListener;
|
||||
class nsIEventTarget;
|
||||
class nsIOutputStream;
|
||||
@ -101,6 +102,7 @@ class FetchDriver final : public nsIStreamListener,
|
||||
|
||||
FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
|
||||
nsILoadGroup* aLoadGroup, nsIEventTarget* aMainThreadEventTarget,
|
||||
nsICookieSettings* aCookieSettings,
|
||||
PerformanceStorage* aPerformanceStorage, bool aIsTrackingFetch);
|
||||
|
||||
nsresult Fetch(AbortSignalImpl* aSignalImpl, FetchDriverObserver* aObserver);
|
||||
@ -136,6 +138,8 @@ class FetchDriver final : public nsIStreamListener,
|
||||
nsAutoPtr<SRICheckDataVerifier> mSRIDataVerifier;
|
||||
nsCOMPtr<nsIEventTarget> mMainThreadEventTarget;
|
||||
|
||||
nsCOMPtr<nsICookieSettings> mCookieSettings;
|
||||
|
||||
// This is set only when Fetch is used in workers.
|
||||
RefPtr<PerformanceStorage> mPerformanceStorage;
|
||||
|
||||
|
@ -1016,6 +1016,7 @@ nsresult nsCSPContext::SendReports(
|
||||
mLoadingPrincipal,
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_CSP_REPORT,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "mozilla/dom/WorkerRunnable.h"
|
||||
#include "mozilla/dom/WorkerScope.h"
|
||||
#include "mozilla/dom/ipc/StructuredCloneData.h"
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
#include "mozilla/net/NeckoChannelParams.h"
|
||||
#include "mozilla/StaticPrefs.h"
|
||||
#include "mozilla/Unused.h"
|
||||
@ -1727,6 +1728,10 @@ nsresult ServiceWorkerPrivate::SpawnWorkerIfNeeded(WakeUpReason aWhy,
|
||||
nsContentUtils::StorageAllowedForServiceWorker(info.mPrincipal);
|
||||
info.mStorageAllowed =
|
||||
access > nsContentUtils::StorageAccess::ePrivateBrowsing;
|
||||
|
||||
info.mCookieSettings = mozilla::net::CookieSettings::Create();
|
||||
MOZ_ASSERT(info.mCookieSettings);
|
||||
|
||||
info.mOriginAttributes = mInfo->GetOriginAttributes();
|
||||
|
||||
// Verify that we don't have any CSP on pristine principal.
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "mozilla/dom/WorkerCommon.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
#include "nsICacheInfoChannel.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIStreamLoader.h"
|
||||
@ -657,12 +658,17 @@ nsresult CompareNetwork::Initialize(nsIPrincipal* aPrincipal,
|
||||
mIsMainScript ? nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER
|
||||
: nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS;
|
||||
|
||||
// Create a new cookieSettings.
|
||||
nsCOMPtr<nsICookieSettings> cookieSettings =
|
||||
mozilla::net::CookieSettings::Create();
|
||||
|
||||
// Note that because there is no "serviceworker" RequestContext type, we can
|
||||
// use the TYPE_INTERNAL_SCRIPT content policy types when loading a service
|
||||
// worker.
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel), uri, aPrincipal, secFlags,
|
||||
contentPolicyType, nullptr, /* aPerformanceStorage */
|
||||
loadGroup, nullptr /* aCallbacks */, mLoadFlags);
|
||||
contentPolicyType, cookieSettings,
|
||||
nullptr /* aPerformanceStorage */, loadGroup,
|
||||
nullptr /* aCallbacks */, mLoadFlags);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -62,6 +62,7 @@
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/dom/HTMLSharedElement.h"
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
#include "mozilla/Printf.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@ -1234,11 +1235,16 @@ nsresult nsWebBrowserPersist::SaveURIInternal(
|
||||
loadFlags |= nsIRequest::LOAD_FROM_CACHE;
|
||||
}
|
||||
|
||||
// Create a new cookieSettings for this download in order to send cookies
|
||||
// based on the current state of the prefs/permissions.
|
||||
nsCOMPtr<nsICookieSettings> cookieSettings =
|
||||
mozilla::net::CookieSettings::Create();
|
||||
|
||||
// Open a channel to the URI
|
||||
nsCOMPtr<nsIChannel> inputChannel;
|
||||
rv = NS_NewChannel(getter_AddRefs(inputChannel), aURI, aTriggeringPrincipal,
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_SAVEAS_DOWNLOAD,
|
||||
nsIContentPolicy::TYPE_SAVEAS_DOWNLOAD, cookieSettings,
|
||||
nullptr, // aPerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
static_cast<nsIInterfaceRequestor *>(this), loadFlags);
|
||||
|
@ -125,17 +125,15 @@ nsresult ConstructURI(const nsAString& aScriptURL, nsIURI* baseURI,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ChannelFromScriptURL(nsIPrincipal* principal, Document* parentDoc,
|
||||
WorkerPrivate* aWorkerPrivate,
|
||||
nsILoadGroup* loadGroup, nsIIOService* ios,
|
||||
nsIScriptSecurityManager* secMan,
|
||||
nsIURI* aScriptURL,
|
||||
const Maybe<ClientInfo>& aClientInfo,
|
||||
const Maybe<ServiceWorkerDescriptor>& aController,
|
||||
bool aIsMainScript,
|
||||
WorkerScriptType aWorkerScriptType,
|
||||
nsContentPolicyType aMainScriptContentPolicyType,
|
||||
nsLoadFlags aLoadFlags, nsIChannel** aChannel) {
|
||||
nsresult ChannelFromScriptURL(
|
||||
nsIPrincipal* principal, Document* parentDoc, WorkerPrivate* aWorkerPrivate,
|
||||
nsILoadGroup* loadGroup, nsIIOService* ios,
|
||||
nsIScriptSecurityManager* secMan, nsIURI* aScriptURL,
|
||||
const Maybe<ClientInfo>& aClientInfo,
|
||||
const Maybe<ServiceWorkerDescriptor>& aController, bool aIsMainScript,
|
||||
WorkerScriptType aWorkerScriptType,
|
||||
nsContentPolicyType aMainScriptContentPolicyType, nsLoadFlags aLoadFlags,
|
||||
nsICookieSettings* aCookieSettings, nsIChannel** aChannel) {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
nsresult rv;
|
||||
@ -206,11 +204,7 @@ nsresult ChannelFromScriptURL(nsIPrincipal* principal, Document* parentDoc,
|
||||
nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER);
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
// If we have the document, use it. Unfortunately, for dedicated workers
|
||||
// 'parentDoc' ends up being the parent document, which is not the document
|
||||
// that we want to use. So make sure to avoid using 'parentDoc' in that
|
||||
// situation.
|
||||
if (parentDoc && parentDoc->NodePrincipal() == principal) {
|
||||
if (parentDoc) {
|
||||
rv = NS_NewChannel(getter_AddRefs(channel), uri, parentDoc, secFlags,
|
||||
contentPolicyType,
|
||||
nullptr, // aPerformanceStorage
|
||||
@ -234,13 +228,13 @@ nsresult ChannelFromScriptURL(nsIPrincipal* principal, Document* parentDoc,
|
||||
if (aClientInfo.isSome()) {
|
||||
rv = NS_NewChannel(getter_AddRefs(channel), uri, principal,
|
||||
aClientInfo.ref(), aController, secFlags,
|
||||
contentPolicyType, performanceStorage, loadGroup,
|
||||
nullptr, // aCallbacks
|
||||
contentPolicyType, aCookieSettings, performanceStorage,
|
||||
loadGroup, nullptr, // aCallbacks
|
||||
aLoadFlags, ios);
|
||||
} else {
|
||||
rv = NS_NewChannel(getter_AddRefs(channel), uri, principal, secFlags,
|
||||
contentPolicyType, performanceStorage, loadGroup,
|
||||
nullptr, // aCallbacks
|
||||
contentPolicyType, aCookieSettings, performanceStorage,
|
||||
loadGroup, nullptr, // aCallbacks
|
||||
aLoadFlags, ios);
|
||||
}
|
||||
|
||||
@ -960,11 +954,11 @@ class ScriptLoaderRunnable final : public nsIRunnable, public nsINamed {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = ChannelFromScriptURL(principal, parentDoc, mWorkerPrivate, loadGroup,
|
||||
ios, secMan, url, mClientInfo, mController,
|
||||
IsMainWorkerScript(), mWorkerScriptType,
|
||||
mWorkerPrivate->ContentPolicyType(), loadFlags,
|
||||
getter_AddRefs(channel));
|
||||
rv = ChannelFromScriptURL(
|
||||
principal, parentDoc, mWorkerPrivate, loadGroup, ios, secMan, url,
|
||||
mClientInfo, mController, IsMainWorkerScript(), mWorkerScriptType,
|
||||
mWorkerPrivate->ContentPolicyType(), loadFlags,
|
||||
mWorkerPrivate->CookieSettings(), getter_AddRefs(channel));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1829,6 +1823,7 @@ class ChannelGetterRunnable final : public WorkerMainThreadRunnable {
|
||||
nsCOMPtr<Document> parentDoc = mWorkerPrivate->GetDocument();
|
||||
|
||||
mLoadInfo.mLoadGroup = mWorkerPrivate->GetLoadGroup();
|
||||
mLoadInfo.mCookieSettings = mWorkerPrivate->CookieSettings();
|
||||
|
||||
// Nested workers use default uri encoding.
|
||||
nsCOMPtr<nsIURI> url;
|
||||
@ -1844,7 +1839,8 @@ class ChannelGetterRunnable final : public WorkerMainThreadRunnable {
|
||||
mLoadInfo.mLoadingPrincipal, parentDoc, mLoadInfo.mLoadGroup, url,
|
||||
clientInfo,
|
||||
// Nested workers are always dedicated.
|
||||
nsIContentPolicy::TYPE_INTERNAL_WORKER, getter_AddRefs(channel));
|
||||
nsIContentPolicy::TYPE_INTERNAL_WORKER, mLoadInfo.mCookieSettings,
|
||||
getter_AddRefs(channel));
|
||||
NS_ENSURE_SUCCESS(mResult, true);
|
||||
|
||||
mResult = mLoadInfo.SetPrincipalFromChannel(channel);
|
||||
@ -2159,7 +2155,8 @@ namespace workerinternals {
|
||||
nsresult ChannelFromScriptURLMainThread(
|
||||
nsIPrincipal* aPrincipal, Document* aParentDoc, nsILoadGroup* aLoadGroup,
|
||||
nsIURI* aScriptURL, const Maybe<ClientInfo>& aClientInfo,
|
||||
nsContentPolicyType aMainScriptContentPolicyType, nsIChannel** aChannel) {
|
||||
nsContentPolicyType aMainScriptContentPolicyType,
|
||||
nsICookieSettings* aCookieSettings, nsIChannel** aChannel) {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
nsCOMPtr<nsIIOService> ios(do_GetIOService());
|
||||
@ -2170,7 +2167,8 @@ nsresult ChannelFromScriptURLMainThread(
|
||||
return ChannelFromScriptURL(
|
||||
aPrincipal, aParentDoc, nullptr, aLoadGroup, ios, secMan, aScriptURL,
|
||||
aClientInfo, Maybe<ServiceWorkerDescriptor>(), true, WorkerScript,
|
||||
aMainScriptContentPolicyType, nsIRequest::LOAD_NORMAL, aChannel);
|
||||
aMainScriptContentPolicyType, nsIRequest::LOAD_NORMAL, aCookieSettings,
|
||||
aChannel);
|
||||
}
|
||||
|
||||
nsresult ChannelFromScriptURLWorkerThread(JSContext* aCx,
|
||||
|
@ -16,6 +16,7 @@ class nsIURI;
|
||||
|
||||
class nsILoadGroup;
|
||||
class nsIChannel;
|
||||
class nsICookieSettings;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -33,7 +34,8 @@ namespace workerinternals {
|
||||
nsresult ChannelFromScriptURLMainThread(
|
||||
nsIPrincipal* aPrincipal, Document* aParentDoc, nsILoadGroup* aLoadGroup,
|
||||
nsIURI* aScriptURL, const Maybe<ClientInfo>& aClientInfo,
|
||||
nsContentPolicyType aContentPolicyType, nsIChannel** aChannel);
|
||||
nsContentPolicyType aContentPolicyType, nsICookieSettings* aCookieSettings,
|
||||
nsIChannel** aChannel);
|
||||
|
||||
nsresult ChannelFromScriptURLWorkerThread(JSContext* aCx,
|
||||
WorkerPrivate* aParent,
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
class nsIChannel;
|
||||
class nsIContentSecurityPolicy;
|
||||
class nsICookieSettings;
|
||||
class nsILoadGroup;
|
||||
class nsIPrincipal;
|
||||
class nsIRunnable;
|
||||
@ -50,6 +51,9 @@ struct WorkerLoadInfoData {
|
||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
|
||||
// Taken from the parent context.
|
||||
nsCOMPtr<nsICookieSettings> mCookieSettings;
|
||||
|
||||
nsCOMPtr<nsIScriptContext> mScriptContext;
|
||||
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
||||
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "ScriptLoader.h"
|
||||
#include "mozilla/dom/ServiceWorkerEvents.h"
|
||||
#include "mozilla/dom/ServiceWorkerManager.h"
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
#include "WorkerCSPEventListener.h"
|
||||
#include "WorkerDebugger.h"
|
||||
#include "WorkerDebuggerManager.h"
|
||||
@ -2475,6 +2476,7 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
|
||||
nsContentUtils::StorageAccess access =
|
||||
nsContentUtils::StorageAllowedForWindow(globalWindow);
|
||||
loadInfo.mStorageAllowed = access > nsContentUtils::StorageAccess::eDeny;
|
||||
loadInfo.mCookieSettings = document->CookieSettings();
|
||||
loadInfo.mOriginAttributes =
|
||||
nsContentUtils::GetOriginAttributes(document);
|
||||
loadInfo.mParentController = globalWindow->GetController();
|
||||
@ -2520,6 +2522,9 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
|
||||
loadInfo.mFromWindow = false;
|
||||
loadInfo.mWindowID = UINT64_MAX;
|
||||
loadInfo.mStorageAllowed = true;
|
||||
loadInfo.mCookieSettings = mozilla::net::CookieSettings::Create();
|
||||
MOZ_ASSERT(loadInfo.mCookieSettings);
|
||||
|
||||
loadInfo.mOriginAttributes = OriginAttributes();
|
||||
}
|
||||
|
||||
@ -2539,10 +2544,10 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
|
||||
getter_AddRefs(url), aScriptURL, document, loadInfo.mBaseURI);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR);
|
||||
|
||||
rv = ChannelFromScriptURLMainThread(loadInfo.mLoadingPrincipal, document,
|
||||
loadInfo.mLoadGroup, url, clientInfo,
|
||||
ContentPolicyType(aWorkerType),
|
||||
getter_AddRefs(loadInfo.mChannel));
|
||||
rv = ChannelFromScriptURLMainThread(
|
||||
loadInfo.mLoadingPrincipal, document, loadInfo.mLoadGroup, url,
|
||||
clientInfo, ContentPolicyType(aWorkerType), loadInfo.mCookieSettings,
|
||||
getter_AddRefs(loadInfo.mChannel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = NS_GetFinalChannelURI(loadInfo.mChannel,
|
||||
|
@ -730,6 +730,12 @@ class WorkerPrivate : public RelativeTimeline {
|
||||
mLoadInfo.mFirstPartyStorageAccessGranted;
|
||||
}
|
||||
|
||||
nsICookieSettings* CookieSettings() const {
|
||||
// Any thread.
|
||||
MOZ_ASSERT(mLoadInfo.mCookieSettings);
|
||||
return mLoadInfo.mCookieSettings;
|
||||
}
|
||||
|
||||
const OriginAttributes& GetOriginAttributes() const {
|
||||
return mLoadInfo.mOriginAttributes;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "mozilla/dom/WorkerRunnable.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
#include "nsIConsoleReportCollector.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsNetUtil.h"
|
||||
@ -269,6 +270,7 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(
|
||||
info.mStorageAllowed = aData.isStorageAccessAllowed();
|
||||
info.mOriginAttributes =
|
||||
BasePrincipal::Cast(principal)->OriginAttributesRef();
|
||||
info.mCookieSettings = net::CookieSettings::Create();
|
||||
|
||||
// Default CSP permissions for now. These will be overrided if necessary
|
||||
// based on the script CSP headers during load in ScriptLoader.
|
||||
@ -301,7 +303,7 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(
|
||||
info.mResolvedScriptURI, clientInfo,
|
||||
aData.isSharedWorker() ? nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER
|
||||
: nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER,
|
||||
getter_AddRefs(info.mChannel));
|
||||
info.mCookieSettings, getter_AddRefs(info.mChannel));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1047,6 +1047,7 @@ nsresult nsXBLService::FetchBindingDocument(
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS,
|
||||
nsIContentPolicy::TYPE_XBL,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
loadGroup);
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "XMLHttpRequest.h"
|
||||
#include "XMLHttpRequestMainThread.h"
|
||||
#include "XMLHttpRequestWorker.h"
|
||||
#include "mozilla/net/CookieSettings.h"
|
||||
#include "nsGlobalWindowInner.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -25,8 +27,23 @@ already_AddRefed<XMLHttpRequest> XMLHttpRequest::Constructor(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICookieSettings> cookieSettings;
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(global);
|
||||
if (window) {
|
||||
Document* document = window->GetExtantDoc();
|
||||
if (NS_WARN_IF(!document)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cookieSettings = document->CookieSettings();
|
||||
} else {
|
||||
// We are here because this is a sandbox.
|
||||
cookieSettings = net::CookieSettings::Create();
|
||||
}
|
||||
|
||||
RefPtr<XMLHttpRequestMainThread> req = new XMLHttpRequestMainThread();
|
||||
req->Construct(principal->GetPrincipal(), global);
|
||||
req->Construct(principal->GetPrincipal(), global, cookieSettings);
|
||||
req->InitParameters(aParams.mMozAnon, aParams.mMozSystem);
|
||||
return req.forget();
|
||||
}
|
||||
|
@ -2334,6 +2334,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel), mRequestURL, mPrincipal,
|
||||
mClientInfo.ref(), mController, secFlags,
|
||||
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
|
||||
mCookieSettings,
|
||||
mPerformanceStorage, // aPerformanceStorage
|
||||
loadGroup,
|
||||
nullptr, // aCallbacks
|
||||
@ -2342,6 +2343,7 @@ nsresult XMLHttpRequestMainThread::CreateChannel() {
|
||||
// Otherwise use the principal.
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel), mRequestURL, mPrincipal,
|
||||
secFlags, nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
|
||||
mCookieSettings,
|
||||
mPerformanceStorage, // aPerformanceStorage
|
||||
loadGroup,
|
||||
nullptr, // aCallbacks
|
||||
|
@ -199,7 +199,8 @@ class XMLHttpRequestMainThread final : public XMLHttpRequest,
|
||||
XMLHttpRequestMainThread();
|
||||
|
||||
void Construct(nsIPrincipal* aPrincipal, nsIGlobalObject* aGlobalObject,
|
||||
nsIURI* aBaseURI = nullptr, nsILoadGroup* aLoadGroup = nullptr,
|
||||
nsICookieSettings* aCookieSettings, nsIURI* aBaseURI = nullptr,
|
||||
nsILoadGroup* aLoadGroup = nullptr,
|
||||
PerformanceStorage* aPerformanceStorage = nullptr,
|
||||
nsICSPEventListener* aCSPEventListener = nullptr) {
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
@ -207,6 +208,7 @@ class XMLHttpRequestMainThread final : public XMLHttpRequest,
|
||||
BindToOwner(aGlobalObject);
|
||||
mBaseURI = aBaseURI;
|
||||
mLoadGroup = aLoadGroup;
|
||||
mCookieSettings = aCookieSettings;
|
||||
mPerformanceStorage = aPerformanceStorage;
|
||||
mCSPEventListener = aCSPEventListener;
|
||||
}
|
||||
@ -494,6 +496,8 @@ class XMLHttpRequestMainThread final : public XMLHttpRequest,
|
||||
|
||||
nsCOMPtr<nsIStreamListener> mXMLParserStreamListener;
|
||||
|
||||
nsCOMPtr<nsICookieSettings> mCookieSettings;
|
||||
|
||||
RefPtr<PerformanceStorage> mPerformanceStorage;
|
||||
nsCOMPtr<nsICSPEventListener> mCSPEventListener;
|
||||
|
||||
|
@ -779,6 +779,7 @@ bool Proxy::Init() {
|
||||
mXHR = new XMLHttpRequestMainThread();
|
||||
mXHR->Construct(mWorkerPrivate->GetPrincipal(),
|
||||
ownerWindow ? ownerWindow->AsGlobal() : nullptr,
|
||||
mWorkerPrivate->CookieSettings(),
|
||||
mWorkerPrivate->GetBaseURI(), mWorkerPrivate->GetLoadGroup(),
|
||||
mWorkerPrivate->GetPerformanceStorage(),
|
||||
mWorkerPrivate->CSPEventListener());
|
||||
|
@ -68,8 +68,9 @@ nsresult nsXMLPrettyPrinter::PrettyPrint(Document* aDocument,
|
||||
nsCOMPtr<Document> xslDocument;
|
||||
rv = nsSyncLoadService::LoadDocument(
|
||||
xslUri, nsIContentPolicy::TYPE_XSLT, nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nullptr, true,
|
||||
mozilla::net::RP_Unset, getter_AddRefs(xslDocument));
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nullptr,
|
||||
aDocument->CookieSettings(), true, mozilla::net::RP_Unset,
|
||||
getter_AddRefs(xslDocument));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Transform the document
|
||||
|
@ -38,7 +38,8 @@ nsresult txParseDocumentFromURI(const nsAString& aHref,
|
||||
rv = nsSyncLoadService::LoadDocument(
|
||||
documentURI, nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST,
|
||||
loaderDocument->NodePrincipal(),
|
||||
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS, loadGroup, true,
|
||||
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS, loadGroup,
|
||||
loaderDocument->CookieSettings(), true,
|
||||
loaderDocument->GetReferrerPolicy(), &theDocument);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -563,7 +563,8 @@ nsresult txSyncCompileObserver::loadURI(const nsAString& aUri,
|
||||
|
||||
rv = nsSyncLoadService::LoadDocument(
|
||||
uri, nsIContentPolicy::TYPE_XSLT, referrerPrincipal,
|
||||
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS, nullptr, false,
|
||||
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS, nullptr,
|
||||
source ? source->OwnerDoc()->CookieSettings() : nullptr, false,
|
||||
aReferrerPolicy, getter_AddRefs(document));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -249,6 +249,7 @@ nsresult nsAutoConfig::downloadAutoConfig() {
|
||||
getter_AddRefs(channel), url, nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // loadGroup
|
||||
nullptr, // aCallbacks
|
||||
|
@ -835,10 +835,11 @@ static nsresult NewImageChannel(
|
||||
// outside a document, in which case the triggeringPrincipal and
|
||||
// triggeringPrincipal should always be the systemPrincipal.
|
||||
// However, there are exceptions: one is Notifications which create a
|
||||
// channel in the parent prcoess in which case we can't get a
|
||||
// channel in the parent process in which case we can't get a
|
||||
// requestingNode.
|
||||
rv = NS_NewChannel(aResult, aURI, nsContentUtils::GetSystemPrincipal(),
|
||||
securityFlags, aPolicyType,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // loadGroup
|
||||
callbacks, aLoadFlags);
|
||||
|
@ -238,6 +238,7 @@ class MOZ_STACK_CLASS ComponentLoaderInfo {
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_SCRIPT,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // aPerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
|
@ -417,6 +417,7 @@ nsresult mozJSSubScriptLoader::ReadScriptAsync(nsIURI* uri,
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // aPerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
@ -456,6 +457,7 @@ bool mozJSSubScriptLoader::ReadScript(nsIURI* uri, JSContext* cx,
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
|
@ -1393,6 +1393,7 @@ nsresult Loader::LoadSheet(SheetLoadData* aLoadData,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
nsCOMPtr<nsICookieSettings> cookieSettings;
|
||||
if (mDocument) {
|
||||
loadGroup = mDocument->GetDocumentLoadGroup();
|
||||
// load for a document with no loadgrup indicates that something is
|
||||
@ -1402,6 +1403,8 @@ nsresult Loader::LoadSheet(SheetLoadData* aLoadData,
|
||||
SheetComplete(aLoadData, NS_ERROR_UNEXPECTED);
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
cookieSettings = mDocument->CookieSettings();
|
||||
}
|
||||
#ifdef DEBUG
|
||||
mSyncCallback = true;
|
||||
@ -1443,7 +1446,7 @@ nsresult Loader::LoadSheet(SheetLoadData* aLoadData,
|
||||
// triggeringPrincipal should always be the systemPrincipal.
|
||||
rv = NS_NewChannel(getter_AddRefs(channel), aLoadData->mURI,
|
||||
nsContentUtils::GetSystemPrincipal(), securityFlags,
|
||||
contentPolicyType,
|
||||
contentPolicyType, cookieSettings,
|
||||
nullptr, // aPerformanceStorage
|
||||
loadGroup,
|
||||
nullptr, // aCallbacks
|
||||
|
@ -786,14 +786,31 @@ LoadInfo::GetCookiePolicy(uint32_t* aResult) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
already_AddRefed<nsICookieSettings> CreateCookieSettings(
|
||||
nsContentPolicyType aContentPolicyType) {
|
||||
if (StaticPrefs::network_cookieSettings_unblocked_for_testing()) {
|
||||
return CookieSettings::Create();
|
||||
}
|
||||
|
||||
// These contentPolictTypes require a real CookieSettings because favicon and
|
||||
// save-as requests must send cookies. Anything else should not send/receive
|
||||
// cookies.
|
||||
if (aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON ||
|
||||
aContentPolicyType == nsIContentPolicy::TYPE_SAVEAS_DOWNLOAD) {
|
||||
return CookieSettings::Create();
|
||||
}
|
||||
|
||||
return CookieSettings::CreateBlockingAll();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetCookieSettings(nsICookieSettings** aCookieSettings) {
|
||||
if (!mCookieSettings) {
|
||||
if (StaticPrefs::network_cookieSettings_unblocked_for_testing()) {
|
||||
mCookieSettings = CookieSettings::Create();
|
||||
} else {
|
||||
mCookieSettings = CookieSettings::CreateBlockingAll();
|
||||
}
|
||||
mCookieSettings = CreateCookieSettings(mInternalContentPolicyType);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICookieSettings> cookieSettings = mCookieSettings;
|
||||
@ -801,6 +818,14 @@ LoadInfo::GetCookieSettings(nsICookieSettings** aCookieSettings) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::SetCookieSettings(nsICookieSettings* aCookieSettings) {
|
||||
MOZ_ASSERT(aCookieSettings);
|
||||
// We allow the overwrite of CookieSettings.
|
||||
mCookieSettings = aCookieSettings;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void LoadInfo::SetIncludeCookiesSecFlag() {
|
||||
MOZ_ASSERT((mSecurityFlags & sCookiePolicyMask) ==
|
||||
nsILoadInfo::SEC_COOKIES_DEFAULT);
|
||||
|
@ -191,6 +191,7 @@ static inline already_AddRefed<nsIChannel> SetupIPCheckChannel(bool ipv4) {
|
||||
getter_AddRefs(channel), uri, nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // aPerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
nullptr,
|
||||
|
@ -1246,7 +1246,8 @@ nsresult Predictor::Prefetch(nsIURI *uri, nsIURI *referrer,
|
||||
nsresult rv = NS_NewChannel(
|
||||
getter_AddRefs(channel), uri, nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER, nullptr, /* aPerformanceStorage */
|
||||
nsIContentPolicy::TYPE_OTHER, nullptr, /* nsICookieSettings */
|
||||
nullptr, /* aPerformanceStorage */
|
||||
nullptr, /* aLoadGroup */
|
||||
nullptr, /* aCallbacks */
|
||||
nsIRequest::LOAD_BACKGROUND);
|
||||
|
@ -431,7 +431,7 @@ interface nsILoadInfo : nsISupports
|
||||
* The cookie settings inherited from the top-level document's loadInfo.
|
||||
* It cannot be null.
|
||||
*/
|
||||
readonly attribute nsICookieSettings cookieSettings;
|
||||
attribute nsICookieSettings cookieSettings;
|
||||
|
||||
/**
|
||||
* If forceInheritPrincipal is true, the data coming from the channel should
|
||||
|
@ -220,6 +220,7 @@ nsresult nsIncrementalDownload::ProcessTimeout() {
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // loadGroup
|
||||
this, // aCallbacks
|
||||
|
@ -298,19 +298,20 @@ nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri,
|
||||
nsIPrincipal *aLoadingPrincipal,
|
||||
nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
PerformanceStorage *aPerformanceStorage /* nullptr */,
|
||||
nsICookieSettings *aCookieSettings /* = nullptr */,
|
||||
PerformanceStorage *aPerformanceStorage /* = nullptr */,
|
||||
nsILoadGroup *aLoadGroup /* = nullptr */,
|
||||
nsIInterfaceRequestor *aCallbacks /* = nullptr */,
|
||||
nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */,
|
||||
nsIIOService *aIoService /* = nullptr */) {
|
||||
return NS_NewChannelInternal(outChannel, aUri,
|
||||
nullptr, // aLoadingNode,
|
||||
aLoadingPrincipal,
|
||||
nullptr, // aTriggeringPrincipal
|
||||
Maybe<ClientInfo>(),
|
||||
Maybe<ServiceWorkerDescriptor>(), aSecurityFlags,
|
||||
aContentPolicyType, aPerformanceStorage,
|
||||
aLoadGroup, aCallbacks, aLoadFlags, aIoService);
|
||||
return NS_NewChannelInternal(
|
||||
outChannel, aUri,
|
||||
nullptr, // aLoadingNode,
|
||||
aLoadingPrincipal,
|
||||
nullptr, // aTriggeringPrincipal
|
||||
Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags,
|
||||
aContentPolicyType, aCookieSettings, aPerformanceStorage, aLoadGroup,
|
||||
aCallbacks, aLoadFlags, aIoService);
|
||||
}
|
||||
|
||||
nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri,
|
||||
@ -319,7 +320,8 @@ nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri,
|
||||
const Maybe<ServiceWorkerDescriptor> &aController,
|
||||
nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
PerformanceStorage *aPerformanceStorage /* nullptr */,
|
||||
nsICookieSettings *aCookieSettings /* = nullptr */,
|
||||
PerformanceStorage *aPerformanceStorage /* = nullptr */,
|
||||
nsILoadGroup *aLoadGroup /* = nullptr */,
|
||||
nsIInterfaceRequestor *aCallbacks /* = nullptr */,
|
||||
nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */,
|
||||
@ -335,8 +337,9 @@ nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri,
|
||||
aLoadingPrincipal,
|
||||
nullptr, // aTriggeringPrincipal
|
||||
loadingClientInfo, aController, aSecurityFlags,
|
||||
aContentPolicyType, aPerformanceStorage,
|
||||
aLoadGroup, aCallbacks, aLoadFlags, aIoService);
|
||||
aContentPolicyType, aCookieSettings,
|
||||
aPerformanceStorage, aLoadGroup, aCallbacks,
|
||||
aLoadFlags, aIoService);
|
||||
}
|
||||
|
||||
nsresult NS_NewChannelInternal(
|
||||
@ -345,7 +348,8 @@ nsresult NS_NewChannelInternal(
|
||||
const Maybe<ClientInfo> &aLoadingClientInfo,
|
||||
const Maybe<ServiceWorkerDescriptor> &aController,
|
||||
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
|
||||
PerformanceStorage *aPerformanceStorage /* nullptr */,
|
||||
nsICookieSettings *aCookieSettings /* = nullptr */,
|
||||
PerformanceStorage *aPerformanceStorage /* = nullptr */,
|
||||
nsILoadGroup *aLoadGroup /* = nullptr */,
|
||||
nsIInterfaceRequestor *aCallbacks /* = nullptr */,
|
||||
nsLoadFlags aLoadFlags /* = nsIRequest::LOAD_NORMAL */,
|
||||
@ -389,9 +393,16 @@ nsresult NS_NewChannelInternal(
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (aPerformanceStorage) {
|
||||
if (aPerformanceStorage || aCookieSettings) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
|
||||
loadInfo->SetPerformanceStorage(aPerformanceStorage);
|
||||
|
||||
if (aPerformanceStorage) {
|
||||
loadInfo->SetPerformanceStorage(aPerformanceStorage);
|
||||
}
|
||||
|
||||
if (aCookieSettings) {
|
||||
loadInfo->SetCookieSettings(aCookieSettings);
|
||||
}
|
||||
}
|
||||
|
||||
channel.forget(outChannel);
|
||||
@ -415,7 +426,8 @@ NS_NewChannelWithTriggeringPrincipal(
|
||||
outChannel, aUri, aLoadingNode, aLoadingNode->NodePrincipal(),
|
||||
aTriggeringPrincipal, Maybe<ClientInfo>(),
|
||||
Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType,
|
||||
aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService);
|
||||
aLoadingNode->OwnerDoc()->CookieSettings(), aPerformanceStorage,
|
||||
aLoadGroup, aCallbacks, aLoadFlags, aIoService);
|
||||
}
|
||||
|
||||
// See NS_NewChannelInternal for usage and argument description
|
||||
@ -423,6 +435,7 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
|
||||
nsIChannel **outChannel, nsIURI *aUri, nsIPrincipal *aLoadingPrincipal,
|
||||
nsIPrincipal *aTriggeringPrincipal, nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
nsICookieSettings *aCookieSettings /* = nullptr */,
|
||||
PerformanceStorage *aPerformanceStorage /* = nullptr */,
|
||||
nsILoadGroup *aLoadGroup /* = nullptr */,
|
||||
nsIInterfaceRequestor *aCallbacks /* = nullptr */,
|
||||
@ -435,7 +448,8 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
|
||||
nullptr, // aLoadingNode
|
||||
aLoadingPrincipal, aTriggeringPrincipal, Maybe<ClientInfo>(),
|
||||
Maybe<ServiceWorkerDescriptor>(), aSecurityFlags, aContentPolicyType,
|
||||
aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService);
|
||||
aCookieSettings, aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags,
|
||||
aIoService);
|
||||
}
|
||||
|
||||
// See NS_NewChannelInternal for usage and argument description
|
||||
@ -444,6 +458,7 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
|
||||
nsIPrincipal *aTriggeringPrincipal, const ClientInfo &aLoadingClientInfo,
|
||||
const Maybe<ServiceWorkerDescriptor> &aController,
|
||||
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
|
||||
nsICookieSettings *aCookieSettings /* = nullptr */,
|
||||
PerformanceStorage *aPerformanceStorage /* = nullptr */,
|
||||
nsILoadGroup *aLoadGroup /* = nullptr */,
|
||||
nsIInterfaceRequestor *aCallbacks /* = nullptr */,
|
||||
@ -455,12 +470,12 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
|
||||
Maybe<ClientInfo> loadingClientInfo;
|
||||
loadingClientInfo.emplace(aLoadingClientInfo);
|
||||
|
||||
return NS_NewChannelInternal(outChannel, aUri,
|
||||
nullptr, // aLoadingNode
|
||||
aLoadingPrincipal, aTriggeringPrincipal,
|
||||
loadingClientInfo, aController, aSecurityFlags,
|
||||
aContentPolicyType, aPerformanceStorage,
|
||||
aLoadGroup, aCallbacks, aLoadFlags, aIoService);
|
||||
return NS_NewChannelInternal(
|
||||
outChannel, aUri,
|
||||
nullptr, // aLoadingNode
|
||||
aLoadingPrincipal, aTriggeringPrincipal, loadingClientInfo, aController,
|
||||
aSecurityFlags, aContentPolicyType, aCookieSettings, aPerformanceStorage,
|
||||
aLoadGroup, aCallbacks, aLoadFlags, aIoService);
|
||||
}
|
||||
|
||||
nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri,
|
||||
@ -476,8 +491,8 @@ nsresult NS_NewChannel(nsIChannel **outChannel, nsIURI *aUri,
|
||||
outChannel, aUri, aLoadingNode, aLoadingNode->NodePrincipal(),
|
||||
nullptr, // aTriggeringPrincipal
|
||||
Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags,
|
||||
aContentPolicyType, aPerformanceStorage, aLoadGroup, aCallbacks,
|
||||
aLoadFlags, aIoService);
|
||||
aContentPolicyType, aLoadingNode->OwnerDoc()->CookieSettings(),
|
||||
aPerformanceStorage, aLoadGroup, aCallbacks, aLoadFlags, aIoService);
|
||||
}
|
||||
|
||||
nsresult NS_GetIsDocumentChannel(nsIChannel *aChannel, bool *aIsDocument) {
|
||||
@ -909,6 +924,7 @@ nsresult NS_NewStreamLoaderInternal(
|
||||
nullptr, // aTriggeringPrincipal
|
||||
Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), aSecurityFlags,
|
||||
aContentPolicyType,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
aLoadGroup, aCallbacks, aLoadFlags);
|
||||
|
||||
|
@ -32,6 +32,7 @@ class nsIAuthPrompt;
|
||||
class nsIAuthPrompt2;
|
||||
class nsIChannel;
|
||||
class nsIChannelPolicy;
|
||||
class nsICookieSettings;
|
||||
class nsIDownloadObserver;
|
||||
class nsIEventTarget;
|
||||
class nsIFileProtocolHandler;
|
||||
@ -166,6 +167,7 @@ nsresult NS_NewChannelInternal(
|
||||
const mozilla::Maybe<mozilla::dom::ClientInfo> &aLoadingClientInfo,
|
||||
const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor> &aController,
|
||||
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
|
||||
nsICookieSettings *aCookieSettings = nullptr,
|
||||
mozilla::dom::PerformanceStorage *aPerformanceStorage = nullptr,
|
||||
nsILoadGroup *aLoadGroup = nullptr,
|
||||
nsIInterfaceRequestor *aCallbacks = nullptr,
|
||||
@ -198,6 +200,7 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
|
||||
nsIChannel **outChannel, nsIURI *aUri, nsIPrincipal *aLoadingPrincipal,
|
||||
nsIPrincipal *aTriggeringPrincipal, nsSecurityFlags aSecurityFlags,
|
||||
nsContentPolicyType aContentPolicyType,
|
||||
nsICookieSettings *aCookieSettings = nullptr,
|
||||
mozilla::dom::PerformanceStorage *aPerformanceStorage = nullptr,
|
||||
nsILoadGroup *aLoadGroup = nullptr,
|
||||
nsIInterfaceRequestor *aCallbacks = nullptr,
|
||||
@ -211,6 +214,7 @@ nsresult NS_NewChannelWithTriggeringPrincipal(
|
||||
const mozilla::dom::ClientInfo &aLoadingClientInfo,
|
||||
const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor> &aController,
|
||||
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
|
||||
nsICookieSettings *aCookieSettings = nullptr,
|
||||
mozilla::dom::PerformanceStorage *aPerformanceStorage = nullptr,
|
||||
nsILoadGroup *aLoadGroup = nullptr,
|
||||
nsIInterfaceRequestor *aCallbacks = nullptr,
|
||||
@ -231,6 +235,7 @@ nsresult NS_NewChannel(
|
||||
nsresult NS_NewChannel(
|
||||
nsIChannel **outChannel, nsIURI *aUri, nsIPrincipal *aLoadingPrincipal,
|
||||
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
|
||||
nsICookieSettings *aCookieSettings = nullptr,
|
||||
mozilla::dom::PerformanceStorage *aPerformanceStorage = nullptr,
|
||||
nsILoadGroup *aLoadGroup = nullptr,
|
||||
nsIInterfaceRequestor *aCallbacks = nullptr,
|
||||
@ -243,6 +248,7 @@ nsresult NS_NewChannel(
|
||||
const mozilla::dom::ClientInfo &aLoadingClientInfo,
|
||||
const mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor> &aController,
|
||||
nsSecurityFlags aSecurityFlags, nsContentPolicyType aContentPolicyType,
|
||||
nsICookieSettings *aCookieSettings = nullptr,
|
||||
mozilla::dom::PerformanceStorage *aPerformanceStorage = nullptr,
|
||||
nsILoadGroup *aLoadGroup = nullptr,
|
||||
nsIInterfaceRequestor *aCallbacks = nullptr,
|
||||
|
@ -637,7 +637,8 @@ void nsPACMan::ContinueLoadingAfterPACUriKnown() {
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // PerformanceStorage,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
nsIRequest::LOAD_NORMAL, ios);
|
||||
|
@ -40,10 +40,29 @@ class PermissionComparator {
|
||||
}
|
||||
};
|
||||
|
||||
class ReleaseCookiePermissions final : public Runnable {
|
||||
public:
|
||||
explicit ReleaseCookiePermissions(nsTArray<RefPtr<nsIPermission>>& aArray)
|
||||
: Runnable("ReleaseCookiePermissions") {
|
||||
mArray.SwapElements(aArray);
|
||||
}
|
||||
|
||||
NS_IMETHOD Run() override {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mArray.Clear();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsTArray<RefPtr<nsIPermission>> mArray;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
already_AddRefed<nsICookieSettings> CookieSettings::CreateBlockingAll() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
RefPtr<CookieSettings> cookieSettings =
|
||||
new CookieSettings(nsICookieService::BEHAVIOR_REJECT, eFixed);
|
||||
return cookieSettings.forget();
|
||||
@ -51,15 +70,30 @@ already_AddRefed<nsICookieSettings> CookieSettings::CreateBlockingAll() {
|
||||
|
||||
// static
|
||||
already_AddRefed<nsICookieSettings> CookieSettings::Create() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
RefPtr<CookieSettings> cookieSettings = new CookieSettings(
|
||||
StaticPrefs::network_cookie_cookieBehavior(), eProgressive);
|
||||
return cookieSettings.forget();
|
||||
}
|
||||
|
||||
CookieSettings::CookieSettings(uint32_t aCookieBehavior, State aState)
|
||||
: mCookieBehavior(aCookieBehavior), mState(aState) {}
|
||||
: mCookieBehavior(aCookieBehavior), mState(aState) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
||||
CookieSettings::~CookieSettings() = default;
|
||||
CookieSettings::~CookieSettings() {
|
||||
if (!NS_IsMainThread() && !mCookiePermissions.IsEmpty()) {
|
||||
nsCOMPtr<nsIEventTarget> systemGroupEventTarget =
|
||||
mozilla::SystemGroup::EventTargetFor(mozilla::TaskCategory::Other);
|
||||
MOZ_ASSERT(systemGroupEventTarget);
|
||||
|
||||
RefPtr<Runnable> r = new ReleaseCookiePermissions(mCookiePermissions);
|
||||
MOZ_ASSERT(mCookiePermissions.IsEmpty());
|
||||
|
||||
systemGroupEventTarget->Dispatch(r.forget());
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CookieSettings::GetCookieBehavior(uint32_t* aCookieBehavior) {
|
||||
@ -70,6 +104,7 @@ CookieSettings::GetCookieBehavior(uint32_t* aCookieBehavior) {
|
||||
NS_IMETHODIMP
|
||||
CookieSettings::CookiePermission(nsIPrincipal* aPrincipal,
|
||||
uint32_t* aCookiePermission) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ENSURE_ARG_POINTER(aPrincipal);
|
||||
NS_ENSURE_ARG_POINTER(aCookiePermission);
|
||||
|
||||
@ -118,6 +153,8 @@ CookieSettings::CookiePermission(nsIPrincipal* aPrincipal,
|
||||
}
|
||||
|
||||
void CookieSettings::Serialize(CookieSettingsArgs& aData) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
aData.isFixed() = mState == eFixed;
|
||||
aData.cookieBehavior() = mCookieBehavior;
|
||||
|
||||
@ -147,6 +184,8 @@ void CookieSettings::Serialize(CookieSettingsArgs& aData) {
|
||||
|
||||
/* static */ void CookieSettings::Deserialize(
|
||||
const CookieSettingsArgs& aData, nsICookieSettings** aCookieSettings) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
CookiePermissionList list;
|
||||
for (const CookiePermissionData& data : aData.cookiePermissions()) {
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
@ -173,6 +212,7 @@ void CookieSettings::Serialize(CookieSettingsArgs& aData) {
|
||||
}
|
||||
|
||||
void CookieSettings::Merge(const CookieSettingsArgs& aData) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mCookieBehavior == aData.cookieBehavior());
|
||||
|
||||
if (mState == eFixed) {
|
||||
|
@ -24,7 +24,7 @@ class CookieSettings final : public nsICookieSettings {
|
||||
public:
|
||||
typedef nsTArray<RefPtr<nsIPermission>> CookiePermissionList;
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSICOOKIESETTINGS
|
||||
|
||||
static already_AddRefed<nsICookieSettings> CreateBlockingAll();
|
||||
|
@ -236,6 +236,7 @@ nsresult TRR::SendHTTPRequest() {
|
||||
getter_AddRefs(mChannel), dnsURI, nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
this,
|
||||
|
@ -1993,6 +1993,7 @@ nsUrlClassifierDBService::SendThreatHitReport(nsIChannel* aChannel,
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // aPerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, loadFlags);
|
||||
|
@ -133,6 +133,7 @@ nsresult nsUrlClassifierStreamUpdater::FetchUpdate(
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // aPerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
this, // aInterfaceRequestor
|
||||
|
@ -166,6 +166,7 @@ nsresult nsManifestCheck::Begin() {
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel), mURI, mLoadingPrincipal,
|
||||
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // loadGroup
|
||||
nullptr, // aCallbacks
|
||||
@ -335,6 +336,7 @@ nsresult nsOfflineCacheUpdateItem::OpenChannel(nsOfflineCacheUpdate *aUpdate) {
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel), mURI, mLoadingPrincipal,
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // aLoadGroup
|
||||
this, // aCallbacks
|
||||
|
@ -127,7 +127,7 @@ nsresult nsPrefetchNode::OpenChannel() {
|
||||
getter_AddRefs(mChannel), mURI, source, source->NodePrincipal(),
|
||||
nullptr, // aTriggeringPrincipal
|
||||
Maybe<ClientInfo>(), Maybe<ServiceWorkerDescriptor>(), securityFlags,
|
||||
mPolicyType,
|
||||
mPolicyType, source->OwnerDoc()->CookieSettings(),
|
||||
nullptr, // aPerformanceStorage
|
||||
loadGroup, // aLoadGroup
|
||||
this, // aCallbacks
|
||||
|
@ -71,6 +71,7 @@ nsresult nsDataObj::CStream::Init(nsIURI* pSourceURI,
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel), pSourceURI, aRequestingPrincipal,
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS,
|
||||
aContentPolicyType,
|
||||
nullptr, // nsICookieSettings
|
||||
nullptr, // PerformanceStorage
|
||||
nullptr, // loadGroup
|
||||
nullptr, // aCallbacks
|
||||
|
Loading…
Reference in New Issue
Block a user