mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1251378 - Propagate referrer policy to worker. r=ckerschb
MozReview-Commit-ID: 6BlEl54Dqtc
This commit is contained in:
parent
d1a8ed1358
commit
d9b3fe6291
@ -1202,6 +1202,16 @@ private:
|
||||
mWorkerPrivate->SetCSP(csp);
|
||||
mWorkerPrivate->SetEvalAllowed(evalAllowed);
|
||||
mWorkerPrivate->SetReportCSPViolations(reportEvalViolations);
|
||||
|
||||
// Set ReferrerPolicy, default value is set in GetReferrerPolicy
|
||||
bool hasReferrerPolicy = false;
|
||||
uint32_t rp = mozilla::net::RP_Default;
|
||||
rv = csp->GetReferrerPolicy(&rp, &hasReferrerPolicy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (hasReferrerPolicy) {
|
||||
mWorkerPrivate->SetReferrerPolicy(static_cast<net::ReferrerPolicy>(rp));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parent) {
|
||||
|
@ -1872,6 +1872,7 @@ NS_IMPL_ISUPPORTS(TimerThreadEventTarget, nsIEventTarget)
|
||||
WorkerLoadInfo::WorkerLoadInfo()
|
||||
: mWindowID(UINT64_MAX)
|
||||
, mServiceWorkerID(0)
|
||||
, mReferrerPolicy(net::RP_Default)
|
||||
, mFromWindow(false)
|
||||
, mEvalAllowed(false)
|
||||
, mReportCSPViolations(false)
|
||||
@ -1931,6 +1932,7 @@ WorkerLoadInfo::StealFrom(WorkerLoadInfo& aOther)
|
||||
mServiceWorkerCacheName = aOther.mServiceWorkerCacheName;
|
||||
mWindowID = aOther.mWindowID;
|
||||
mServiceWorkerID = aOther.mServiceWorkerID;
|
||||
mReferrerPolicy = aOther.mReferrerPolicy;
|
||||
mFromWindow = aOther.mFromWindow;
|
||||
mEvalAllowed = aOther.mEvalAllowed;
|
||||
mReportCSPViolations = aOther.mReportCSPViolations;
|
||||
@ -3566,6 +3568,16 @@ WorkerPrivateParent<Derived>::SetPrincipal(nsIPrincipal* aPrincipal,
|
||||
if (mLoadInfo.mCSP) {
|
||||
mLoadInfo.mCSP->GetAllowsEval(&mLoadInfo.mReportCSPViolations,
|
||||
&mLoadInfo.mEvalAllowed);
|
||||
// Set ReferrerPolicy
|
||||
bool hasReferrerPolicy = false;
|
||||
uint32_t rp = mozilla::net::RP_Default;
|
||||
|
||||
nsresult rv = mLoadInfo.mCSP->GetReferrerPolicy(&rp, &hasReferrerPolicy);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
if (hasReferrerPolicy) {
|
||||
mLoadInfo.mReferrerPolicy = static_cast<net::ReferrerPolicy>(rp);
|
||||
}
|
||||
} else {
|
||||
mLoadInfo.mEvalAllowed = true;
|
||||
mLoadInfo.mReportCSPViolations = false;
|
||||
|
@ -651,6 +651,18 @@ public:
|
||||
mLoadInfo.mCSP = aCSP;
|
||||
}
|
||||
|
||||
net::ReferrerPolicy
|
||||
GetReferrerPolicy() const
|
||||
{
|
||||
return mLoadInfo.mReferrerPolicy;
|
||||
}
|
||||
|
||||
void
|
||||
SetReferrerPolicy(net::ReferrerPolicy aReferrerPolicy)
|
||||
{
|
||||
mLoadInfo.mReferrerPolicy = aReferrerPolicy;
|
||||
}
|
||||
|
||||
bool
|
||||
IsEvalAllowed() const
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "mozilla/dom/ChannelInfo.h"
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
|
||||
#define BEGIN_WORKERS_NAMESPACE \
|
||||
namespace mozilla { namespace dom { namespace workers {
|
||||
@ -261,6 +262,7 @@ struct WorkerLoadInfo
|
||||
uint64_t mWindowID;
|
||||
uint64_t mServiceWorkerID;
|
||||
|
||||
net::ReferrerPolicy mReferrerPolicy;
|
||||
bool mFromWindow;
|
||||
bool mEvalAllowed;
|
||||
bool mReportCSPViolations;
|
||||
|
Loading…
Reference in New Issue
Block a user