mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 07:40:42 +00:00
Bug 1557636 Use Referrer info in worker and fix sharedworker's wrong referrer r=baku
SharedWorker should use worker's referrer info instead of default value Differential Revision: https://phabricator.services.mozilla.com/D34861 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
09c4030aa0
commit
1d636c1d2d
@ -7916,56 +7916,6 @@ bool nsContentUtils::IsUpgradableDisplayType(nsContentPolicyType aType) {
|
||||
aType == nsIContentPolicy::TYPE_MEDIA);
|
||||
}
|
||||
|
||||
nsresult nsContentUtils::SetFetchReferrerURIWithPolicy(
|
||||
nsIPrincipal* aPrincipal, Document* aDoc, nsIHttpChannel* aChannel,
|
||||
mozilla::net::ReferrerPolicy aReferrerPolicy) {
|
||||
NS_ENSURE_ARG_POINTER(aPrincipal);
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
|
||||
nsCOMPtr<nsIURI> principalURI;
|
||||
|
||||
if (aPrincipal->IsSystemPrincipal()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
aPrincipal->GetURI(getter_AddRefs(principalURI));
|
||||
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo;
|
||||
if (!aDoc) {
|
||||
referrerInfo = new ReferrerInfo(principalURI, aReferrerPolicy);
|
||||
return aChannel->SetReferrerInfoWithoutClone(referrerInfo);
|
||||
}
|
||||
|
||||
// If it weren't for history.push/replaceState, we could just use the
|
||||
// principal's URI here. But since we want changes to the URI effected
|
||||
// by push/replaceState to be reflected in the XHR referrer, we have to
|
||||
// be more clever.
|
||||
//
|
||||
// If the document's original URI (before any push/replaceStates) matches
|
||||
// our principal, then we use the document's current URI (after
|
||||
// push/replaceStates). Otherwise (if the document is, say, a data:
|
||||
// URI), we just use the principal's URI.
|
||||
nsCOMPtr<nsIURI> docCurURI = aDoc->GetDocumentURI();
|
||||
nsCOMPtr<nsIURI> docOrigURI = aDoc->GetOriginalURI();
|
||||
|
||||
nsCOMPtr<nsIURI> referrerURI;
|
||||
|
||||
if (principalURI && docCurURI && docOrigURI) {
|
||||
bool equal = false;
|
||||
principalURI->Equals(docOrigURI, &equal);
|
||||
if (equal) {
|
||||
referrerURI = docCurURI;
|
||||
}
|
||||
}
|
||||
|
||||
if (!referrerURI) {
|
||||
referrerURI = principalURI;
|
||||
}
|
||||
|
||||
referrerInfo = new ReferrerInfo(referrerURI, aReferrerPolicy);
|
||||
return aChannel->SetReferrerInfoWithoutClone(referrerInfo);
|
||||
}
|
||||
|
||||
// static
|
||||
net::ReferrerPolicy nsContentUtils::GetReferrerPolicyFromHeader(
|
||||
const nsAString& aHeader) {
|
||||
|
@ -2847,25 +2847,6 @@ class nsContentUtils {
|
||||
|
||||
static already_AddRefed<nsPIWindowRoot> GetWindowRoot(Document* aDoc);
|
||||
|
||||
/*
|
||||
* Implements step 3.1 and 3.3 of the Determine request's Referrer algorithm
|
||||
* from the Referrer Policy specification.
|
||||
*
|
||||
* The referrer policy of the document is applied by Necko when using
|
||||
* channels.
|
||||
*
|
||||
* For documents representing an iframe srcdoc attribute, the document sets
|
||||
* its own URI correctly, so this method simply uses the document's original
|
||||
* or current URI as appropriate.
|
||||
*
|
||||
* aDoc may be null.
|
||||
*
|
||||
* https://w3c.github.io/webappsec/specs/referrer-policy/#determine-requests-referrer
|
||||
*/
|
||||
static nsresult SetFetchReferrerURIWithPolicy(
|
||||
nsIPrincipal* aPrincipal, Document* aDoc, nsIHttpChannel* aChannel,
|
||||
mozilla::net::ReferrerPolicy aReferrerPolicy);
|
||||
|
||||
/*
|
||||
* If there is a Referrer-Policy response header in |aChannel|, parse a
|
||||
* referrer policy from the header.
|
||||
|
@ -123,12 +123,11 @@ nsresult FetchUtil::SetRequestReferrer(nsIPrincipal* aPrincipal, Document* aDoc,
|
||||
if (referrer.IsEmpty()) {
|
||||
// This is the case request’s referrer is "no-referrer"
|
||||
referrerInfo = new ReferrerInfo(nullptr, net::RP_No_Referrer);
|
||||
rv = aChannel->SetReferrerInfoWithoutClone(referrerInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (referrer.EqualsLiteral(kFETCH_CLIENT_REFERRER_STR)) {
|
||||
rv = nsContentUtils::SetFetchReferrerURIWithPolicy(aPrincipal, aDoc,
|
||||
aChannel, policy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
referrerInfo = ReferrerInfo::CreateForFetch(aPrincipal, aDoc);
|
||||
// In the first step, we should use referrer info from requetInit
|
||||
referrerInfo = static_cast<ReferrerInfo*>(referrerInfo.get())
|
||||
->CloneWithNewPolicy(policy);
|
||||
} else {
|
||||
// From "Determine request's Referrer" step 3
|
||||
// "If request's referrer is a URL, let referrerSource be request's
|
||||
@ -137,10 +136,11 @@ nsresult FetchUtil::SetRequestReferrer(nsIPrincipal* aPrincipal, Document* aDoc,
|
||||
rv = NS_NewURI(getter_AddRefs(referrerURI), referrer, nullptr, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
referrerInfo = new ReferrerInfo(referrerURI, policy);
|
||||
rv = aChannel->SetReferrerInfoWithoutClone(referrerInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = aChannel->SetReferrerInfoWithoutClone(referrerInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> computedReferrer;
|
||||
referrerInfo = aChannel->GetReferrerInfo();
|
||||
if (referrerInfo) {
|
||||
|
@ -429,7 +429,8 @@ already_AddRefed<Request> Request::Constructor(const GlobalObject& aGlobal,
|
||||
WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
|
||||
if (worker) {
|
||||
worker->AssertIsOnWorkerThread();
|
||||
request->SetEnvironmentReferrerPolicy(worker->GetReferrerPolicy());
|
||||
request->SetEnvironmentReferrerPolicy(
|
||||
static_cast<net::ReferrerPolicy>(worker->GetReferrerPolicy()));
|
||||
principalInfo =
|
||||
MakeUnique<mozilla::ipc::PrincipalInfo>(worker->GetPrincipalInfo());
|
||||
}
|
||||
|
@ -629,6 +629,55 @@ ReferrerInfo::InitWithNode(nsINode* aNode) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsIReferrerInfo> ReferrerInfo::CreateForFetch(
|
||||
nsIPrincipal* aPrincipal, Document* aDoc) {
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo;
|
||||
if (!aPrincipal || aPrincipal->IsSystemPrincipal()) {
|
||||
referrerInfo = new ReferrerInfo(nullptr);
|
||||
return referrerInfo.forget();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> principalURI;
|
||||
aPrincipal->GetURI(getter_AddRefs(principalURI));
|
||||
|
||||
if (!aDoc) {
|
||||
referrerInfo = new ReferrerInfo(principalURI, RP_Unset);
|
||||
return referrerInfo.forget();
|
||||
}
|
||||
|
||||
// If it weren't for history.push/replaceState, we could just use the
|
||||
// principal's URI here. But since we want changes to the URI effected
|
||||
// by push/replaceState to be reflected in the XHR referrer, we have to
|
||||
// be more clever.
|
||||
//
|
||||
// If the document's original URI (before any push/replaceStates) matches
|
||||
// our principal, then we use the document's current URI (after
|
||||
// push/replaceStates). Otherwise (if the document is, say, a data:
|
||||
// URI), we just use the principal's URI.
|
||||
nsCOMPtr<nsIURI> docCurURI = aDoc->GetDocumentURI();
|
||||
nsCOMPtr<nsIURI> docOrigURI = aDoc->GetOriginalURI();
|
||||
|
||||
nsCOMPtr<nsIURI> referrerURI;
|
||||
|
||||
if (principalURI && docCurURI && docOrigURI) {
|
||||
bool equal = false;
|
||||
principalURI->Equals(docOrigURI, &equal);
|
||||
if (equal) {
|
||||
referrerURI = docCurURI;
|
||||
}
|
||||
}
|
||||
|
||||
if (!referrerURI) {
|
||||
referrerURI = principalURI;
|
||||
}
|
||||
|
||||
referrerInfo = new ReferrerInfo(referrerURI, aDoc->GetReferrerPolicy());
|
||||
return referrerInfo.forget();
|
||||
}
|
||||
|
||||
void ReferrerInfo::GetReferrerPolicyFromAtribute(nsINode* aNode,
|
||||
uint32_t& aPolicy) const {
|
||||
aPolicy = mozilla::net::RP_Unset;
|
||||
|
@ -27,6 +27,7 @@ class nsIURI;
|
||||
class nsIChannel;
|
||||
class nsILoadInfo;
|
||||
class nsINode;
|
||||
class nsIPrincipal;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@ -73,6 +74,16 @@ class ReferrerInfo : public nsIReferrerInfo {
|
||||
already_AddRefed<nsIReferrerInfo> CloneWithNewOriginalReferrer(
|
||||
nsIURI* aOriginalReferrer) const;
|
||||
|
||||
/*
|
||||
* Implements step 3.1 and 3.3 of the Determine request's Referrer algorithm
|
||||
* from the Referrer Policy specification.
|
||||
*
|
||||
* https://w3c.github.io/webappsec/specs/referrer-policy/#determine-requests-referrer
|
||||
*/
|
||||
|
||||
static already_AddRefed<nsIReferrerInfo> CreateForFetch(
|
||||
nsIPrincipal* aPrincipal, Document* aDoc);
|
||||
|
||||
/**
|
||||
* Check whether the given referrer's scheme is allowed to be computed and
|
||||
* sent. The whitelist schemes are: http, https, ftp.
|
||||
@ -105,7 +116,7 @@ class ReferrerInfo : public nsIReferrerInfo {
|
||||
nsIURI* aURI = nullptr,
|
||||
bool privateBrowsing = false);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIREFERRERINFO
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
|
||||
|
@ -134,7 +134,8 @@ nsresult ChannelFromScriptURL(
|
||||
const Maybe<ServiceWorkerDescriptor>& aController, bool aIsMainScript,
|
||||
WorkerScriptType aWorkerScriptType,
|
||||
nsContentPolicyType aMainScriptContentPolicyType, nsLoadFlags aLoadFlags,
|
||||
nsICookieSettings* aCookieSettings, nsIChannel** aChannel) {
|
||||
nsICookieSettings* aCookieSettings, nsIReferrerInfo* aReferrerInfo,
|
||||
nsIChannel** aChannel) {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
nsresult rv;
|
||||
@ -247,13 +248,13 @@ nsresult ChannelFromScriptURL(
|
||||
}
|
||||
}
|
||||
|
||||
if (nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel)) {
|
||||
mozilla::net::ReferrerPolicy referrerPolicy =
|
||||
parentDoc ? parentDoc->GetReferrerPolicy() : mozilla::net::RP_Unset;
|
||||
rv = nsContentUtils::SetFetchReferrerURIWithPolicy(
|
||||
principal, parentDoc, httpChannel, referrerPolicy);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
if (aReferrerInfo) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
if (httpChannel) {
|
||||
rv = httpChannel->SetReferrerInfo(aReferrerInfo);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -989,11 +990,20 @@ 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,
|
||||
mWorkerPrivate->CookieSettings(), getter_AddRefs(channel));
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo =
|
||||
ReferrerInfo::CreateForFetch(principal, nullptr);
|
||||
if (parentWorker && !IsMainWorkerScript()) {
|
||||
referrerInfo =
|
||||
static_cast<ReferrerInfo*>(referrerInfo.get())
|
||||
->CloneWithNewPolicy(parentWorker->GetReferrerPolicy());
|
||||
}
|
||||
|
||||
rv = ChannelFromScriptURL(principal, parentDoc, mWorkerPrivate, loadGroup,
|
||||
ios, secMan, url, mClientInfo, mController,
|
||||
IsMainWorkerScript(), mWorkerScriptType,
|
||||
mWorkerPrivate->ContentPolicyType(), loadFlags,
|
||||
mWorkerPrivate->CookieSettings(), referrerInfo,
|
||||
getter_AddRefs(channel));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1233,7 +1243,7 @@ class ScriptLoaderRunnable final : public nsIRunnable, public nsINamed {
|
||||
}
|
||||
}
|
||||
|
||||
mWorkerPrivate->SetReferrerPolicyFromHeaderValue(tRPHeaderCValue);
|
||||
mWorkerPrivate->UpdateReferrerInfoFromHeader(tRPHeaderCValue);
|
||||
|
||||
WorkerPrivate* parent = mWorkerPrivate->GetParent();
|
||||
if (parent) {
|
||||
@ -1348,8 +1358,7 @@ class ScriptLoaderRunnable final : public nsIRunnable, public nsINamed {
|
||||
aCSPReportOnlyHeaderValue);
|
||||
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
mWorkerPrivate->SetReferrerPolicyFromHeaderValue(
|
||||
aReferrerPolicyHeaderValue);
|
||||
mWorkerPrivate->UpdateReferrerInfoFromHeader(aReferrerPolicyHeaderValue);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -1877,12 +1886,18 @@ class ChannelGetterRunnable final : public WorkerMainThreadRunnable {
|
||||
clientInfo.emplace(mClientInfo);
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo =
|
||||
ReferrerInfo::CreateForFetch(mLoadInfo.mLoadingPrincipal, nullptr);
|
||||
mLoadInfo.mReferrerInfo =
|
||||
static_cast<ReferrerInfo*>(referrerInfo.get())
|
||||
->CloneWithNewPolicy(mWorkerPrivate->GetReferrerPolicy());
|
||||
|
||||
mResult = workerinternals::ChannelFromScriptURLMainThread(
|
||||
mLoadInfo.mLoadingPrincipal, parentDoc, mLoadInfo.mLoadGroup, url,
|
||||
clientInfo,
|
||||
// Nested workers are always dedicated.
|
||||
nsIContentPolicy::TYPE_INTERNAL_WORKER, mLoadInfo.mCookieSettings,
|
||||
getter_AddRefs(channel));
|
||||
mLoadInfo.mReferrerInfo, getter_AddRefs(channel));
|
||||
NS_ENSURE_SUCCESS(mResult, true);
|
||||
|
||||
mResult = mLoadInfo.SetPrincipalsAndCSPFromChannel(channel);
|
||||
@ -2240,7 +2255,8 @@ nsresult ChannelFromScriptURLMainThread(
|
||||
nsIPrincipal* aPrincipal, Document* aParentDoc, nsILoadGroup* aLoadGroup,
|
||||
nsIURI* aScriptURL, const Maybe<ClientInfo>& aClientInfo,
|
||||
nsContentPolicyType aMainScriptContentPolicyType,
|
||||
nsICookieSettings* aCookieSettings, nsIChannel** aChannel) {
|
||||
nsICookieSettings* aCookieSettings, nsIReferrerInfo* aReferrerInfo,
|
||||
nsIChannel** aChannel) {
|
||||
AssertIsOnMainThread();
|
||||
|
||||
nsCOMPtr<nsIIOService> ios(do_GetIOService());
|
||||
@ -2252,7 +2268,7 @@ nsresult ChannelFromScriptURLMainThread(
|
||||
aPrincipal, aParentDoc, nullptr, aLoadGroup, ios, secMan, aScriptURL,
|
||||
aClientInfo, Maybe<ServiceWorkerDescriptor>(), true, WorkerScript,
|
||||
aMainScriptContentPolicyType, nsIRequest::LOAD_NORMAL, aCookieSettings,
|
||||
aChannel);
|
||||
aReferrerInfo, aChannel);
|
||||
}
|
||||
|
||||
nsresult ChannelFromScriptURLWorkerThread(JSContext* aCx,
|
||||
|
@ -36,7 +36,7 @@ nsresult ChannelFromScriptURLMainThread(
|
||||
nsIPrincipal* aPrincipal, Document* aParentDoc, nsILoadGroup* aLoadGroup,
|
||||
nsIURI* aScriptURL, const Maybe<ClientInfo>& aClientInfo,
|
||||
nsContentPolicyType aContentPolicyType, nsICookieSettings* aCookieSettings,
|
||||
nsIChannel** aChannel);
|
||||
nsIReferrerInfo* aReferrerInfo, nsIChannel** aChannel);
|
||||
|
||||
nsresult ChannelFromScriptURLWorkerThread(JSContext* aCx,
|
||||
WorkerPrivate* aParent,
|
||||
|
@ -83,7 +83,7 @@ inline void SwapToISupportsArray(SmartPtr<T>& aSrc,
|
||||
WorkerLoadInfoData::WorkerLoadInfoData()
|
||||
: mLoadFlags(nsIRequest::LOAD_NORMAL),
|
||||
mWindowID(UINT64_MAX),
|
||||
mReferrerPolicy(net::RP_Unset),
|
||||
mReferrerInfo(new ReferrerInfo(nullptr)),
|
||||
mFromWindow(false),
|
||||
mEvalAllowed(false),
|
||||
mReportCSPViolations(false),
|
||||
|
@ -118,7 +118,7 @@ struct WorkerLoadInfoData {
|
||||
|
||||
uint64_t mWindowID;
|
||||
|
||||
net::ReferrerPolicy mReferrerPolicy;
|
||||
nsCOMPtr<nsIReferrerInfo> mReferrerInfo;
|
||||
bool mFromWindow;
|
||||
bool mEvalAllowed;
|
||||
bool mReportCSPViolations;
|
||||
|
@ -1323,7 +1323,7 @@ void WorkerPrivate::StoreCSPOnClient() {
|
||||
}
|
||||
}
|
||||
|
||||
void WorkerPrivate::SetReferrerPolicyFromHeaderValue(
|
||||
void WorkerPrivate::UpdateReferrerInfoFromHeader(
|
||||
const nsACString& aReferrerPolicyHeaderValue) {
|
||||
NS_ConvertUTF8toUTF16 headerValue(aReferrerPolicyHeaderValue);
|
||||
|
||||
@ -1337,7 +1337,9 @@ void WorkerPrivate::SetReferrerPolicyFromHeaderValue(
|
||||
return;
|
||||
}
|
||||
|
||||
SetReferrerPolicy(policy);
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo =
|
||||
static_cast<ReferrerInfo*>(GetReferrerInfo())->CloneWithNewPolicy(policy);
|
||||
SetReferrerInfo(referrerInfo);
|
||||
}
|
||||
|
||||
void WorkerPrivate::Traverse(nsCycleCollectionTraversalCallback& aCb) {
|
||||
@ -2518,6 +2520,8 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
|
||||
loadInfo.mWatchedByDevtools = docShell->GetWatchedByDevtools();
|
||||
}
|
||||
|
||||
loadInfo.mReferrerInfo =
|
||||
ReferrerInfo::CreateForFetch(loadInfo.mLoadingPrincipal, document);
|
||||
loadInfo.mFromWindow = true;
|
||||
loadInfo.mWindowID = globalWindow->WindowID();
|
||||
loadInfo.mStorageAccess = StorageAllowedForWindow(globalWindow);
|
||||
@ -2592,7 +2596,7 @@ nsresult WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
|
||||
rv = ChannelFromScriptURLMainThread(
|
||||
loadInfo.mLoadingPrincipal, document, loadInfo.mLoadGroup, url,
|
||||
clientInfo, ContentPolicyType(aWorkerType), loadInfo.mCookieSettings,
|
||||
getter_AddRefs(loadInfo.mChannel));
|
||||
loadInfo.mReferrerInfo, getter_AddRefs(loadInfo.mChannel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = NS_GetFinalChannelURI(loadInfo.mChannel,
|
||||
|
@ -714,15 +714,17 @@ class WorkerPrivate : public RelativeTimeline {
|
||||
return *mLoadInfo.mCSPInfo;
|
||||
}
|
||||
|
||||
void SetReferrerPolicyFromHeaderValue(
|
||||
void UpdateReferrerInfoFromHeader(
|
||||
const nsACString& aReferrerPolicyHeaderValue);
|
||||
|
||||
net::ReferrerPolicy GetReferrerPolicy() const {
|
||||
return mLoadInfo.mReferrerPolicy;
|
||||
nsIReferrerInfo* GetReferrerInfo() const { return mLoadInfo.mReferrerInfo; }
|
||||
|
||||
uint32_t GetReferrerPolicy() const {
|
||||
return mLoadInfo.mReferrerInfo->GetReferrerPolicy();
|
||||
}
|
||||
|
||||
void SetReferrerPolicy(net::ReferrerPolicy aReferrerPolicy) {
|
||||
mLoadInfo.mReferrerPolicy = aReferrerPolicy;
|
||||
void SetReferrerInfo(nsIReferrerInfo* aReferrerInfo) {
|
||||
mLoadInfo.mReferrerInfo = aReferrerInfo;
|
||||
}
|
||||
|
||||
bool IsEvalAllowed() const { return mLoadInfo.mEvalAllowed; }
|
||||
|
@ -217,6 +217,7 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(
|
||||
info.mPrincipalInfo = new PrincipalInfo(aData.principalInfo());
|
||||
info.mStoragePrincipalInfo = new PrincipalInfo(aData.storagePrincipalInfo());
|
||||
|
||||
info.mReferrerInfo = aData.referrerInfo();
|
||||
info.mDomain = aData.domain();
|
||||
info.mPrincipal = principal;
|
||||
info.mStoragePrincipal = storagePrincipal;
|
||||
@ -270,7 +271,7 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(
|
||||
info.mResolvedScriptURI, clientInfo,
|
||||
aData.isSharedWorker() ? nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER
|
||||
: nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER,
|
||||
info.mCookieSettings, getter_AddRefs(info.mChannel));
|
||||
info.mCookieSettings, info.mReferrerInfo, getter_AddRefs(info.mChannel));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
include ClientIPCTypes;
|
||||
include PBackgroundSharedTypes;
|
||||
include URIParams;
|
||||
include DOMTypes;
|
||||
|
||||
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
|
||||
using mozilla::StorageAccess from "mozilla/dom/ClientIPCUtils.h";
|
||||
@ -40,6 +41,8 @@ struct RemoteWorkerData
|
||||
|
||||
IPCClientInfo? clientInfo;
|
||||
|
||||
nsIReferrerInfo referrerInfo;
|
||||
|
||||
StorageAccess storageAccess;
|
||||
|
||||
bool isSharedWorker;
|
||||
|
@ -194,8 +194,8 @@ already_AddRefed<SharedWorker> SharedWorker::Constructor(
|
||||
RemoteWorkerData remoteWorkerData(
|
||||
nsString(aScriptURL), baseURL, resolvedScriptURL, name,
|
||||
loadingPrincipalInfo, principalInfo, storagePrincipalInfo,
|
||||
loadInfo.mDomain, isSecureContext, ipcClientInfo, storageAllowed,
|
||||
true /* sharedWorker */);
|
||||
loadInfo.mDomain, isSecureContext, ipcClientInfo, loadInfo.mReferrerInfo,
|
||||
storageAllowed, true /* sharedWorker */);
|
||||
|
||||
PSharedWorkerChild* pActor = actorChild->SendPSharedWorkerConstructor(
|
||||
remoteWorkerData, loadInfo.mWindowID, portIdentifier);
|
||||
|
@ -2476,10 +2476,9 @@ nsresult XMLHttpRequestMainThread::InitiateFetch(
|
||||
if (!IsSystemXHR()) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
|
||||
nsCOMPtr<Document> doc = owner ? owner->GetExtantDoc() : nullptr;
|
||||
mozilla::net::ReferrerPolicy referrerPolicy =
|
||||
doc ? doc->GetReferrerPolicy() : mozilla::net::RP_Unset;
|
||||
nsContentUtils::SetFetchReferrerURIWithPolicy(
|
||||
mPrincipal, doc, httpChannel, referrerPolicy);
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo =
|
||||
ReferrerInfo::CreateForFetch(mPrincipal, doc);
|
||||
Unused << httpChannel->SetReferrerInfoWithoutClone(referrerInfo);
|
||||
}
|
||||
|
||||
// Some extensions override the http protocol handler and provide their own
|
||||
|
@ -1,4 +0,0 @@
|
||||
[generic.http.html]
|
||||
[The referrer URL is omitted when a\n document served over http requires an http\n sub-resource via shared-worker using the http-rp\n delivery method with keep-origin-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1,4 +0,0 @@
|
||||
[generic.http.html]
|
||||
[The referrer URL is omitted when a\n document served over http requires an http\n sub-resource via shared-worker using the http-rp\n delivery method with no-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1 +0,0 @@
|
||||
leak-threshold: [default:51200]
|
@ -1,4 +0,0 @@
|
||||
[generic.http.html]
|
||||
[The referrer URL is omitted when a\n document served over http requires an http\n sub-resource via shared-worker using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1,4 +0,0 @@
|
||||
[generic.http.html]
|
||||
[The referrer URL is omitted when a\n document served over http requires an http\n sub-resource via shared-worker using the meta-referrer\n delivery method with no-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1 +0,0 @@
|
||||
leak-threshold: [default:51200]
|
@ -1 +0,0 @@
|
||||
leak-threshold: [default:51200]
|
@ -1 +0,0 @@
|
||||
leak-threshold: [default:51200]
|
@ -1 +0,0 @@
|
||||
leak-threshold: [default:51200]
|
@ -1,4 +0,0 @@
|
||||
[generic.http.html]
|
||||
[The referrer URL is origin when a\n document served over http requires an http\n sub-resource via shared-worker using the http-rp\n delivery method with keep-origin-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1,4 +0,0 @@
|
||||
[generic.http.html]
|
||||
[The referrer URL is origin when a\n document served over http requires an http\n sub-resource via shared-worker using the http-rp\n delivery method with no-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1,4 +0,0 @@
|
||||
[generic.http.html]
|
||||
[The referrer URL is origin when a\n document served over http requires an http\n sub-resource via shared-worker using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1,4 +0,0 @@
|
||||
[generic.http.html]
|
||||
[The referrer URL is origin when a\n document served over http requires an http\n sub-resource via shared-worker using the meta-referrer\n delivery method with no-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1,4 +0,0 @@
|
||||
[same-insecure.http.html]
|
||||
[Referrer-Policy: Referrer Policy is set to 'strict-origin-when-cross-origin']
|
||||
expected: FAIL
|
||||
|
@ -1,4 +0,0 @@
|
||||
[insecure-protocol.http.html]
|
||||
[The referrer URL is origin when a\n document served over http requires an http\n sub-resource via shared-worker using the http-rp\n delivery method with keep-origin-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1,4 +0,0 @@
|
||||
[insecure-protocol.http.html]
|
||||
[The referrer URL is origin when a\n document served over http requires an http\n sub-resource via shared-worker using the http-rp\n delivery method with no-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1,4 +0,0 @@
|
||||
[insecure-protocol.http.html]
|
||||
[The referrer URL is origin when a\n document served over http requires an http\n sub-resource via shared-worker using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
@ -1,4 +0,0 @@
|
||||
[insecure-protocol.http.html]
|
||||
[The referrer URL is origin when a\n document served over http requires an http\n sub-resource via shared-worker using the meta-referrer\n delivery method with no-redirect and when\n the target request is same-origin.]
|
||||
expected: FAIL
|
||||
|
Loading…
x
Reference in New Issue
Block a user