mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-08 00:07:30 +09:00
Merge remote-tracking branch 'origin/tracking' into custom
This commit is contained in:
commit
80c4f1d745
79 changed files with 1353 additions and 509 deletions
|
|
@ -58,6 +58,7 @@
|
|||
#include "mozilla/dom/MessageEventBinding.h"
|
||||
#include "mozilla/dom/MessagePort.h"
|
||||
#include "mozilla/dom/MessagePortBinding.h"
|
||||
#include "mozilla/dom/nsCSPUtils.h"
|
||||
#include "mozilla/dom/Performance.h"
|
||||
#include "mozilla/dom/PMessagePort.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
|
@ -549,7 +550,7 @@ private:
|
|||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
if (swm) {
|
||||
swm->HandleError(aCx, aWorkerPrivate->GetPrincipal(),
|
||||
aWorkerPrivate->WorkerName(),
|
||||
aWorkerPrivate->ServiceWorkerScope(),
|
||||
aWorkerPrivate->ScriptURL(),
|
||||
EmptyString(), EmptyString(), EmptyString(),
|
||||
0, 0, JSREPORT_ERROR, JSEXN_ERR);
|
||||
|
|
@ -1254,7 +1255,7 @@ private:
|
|||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
if (swm) {
|
||||
swm->HandleError(aCx, aWorkerPrivate->GetPrincipal(),
|
||||
aWorkerPrivate->WorkerName(),
|
||||
aWorkerPrivate->ServiceWorkerScope(),
|
||||
aWorkerPrivate->ScriptURL(),
|
||||
mReport.mMessage,
|
||||
mReport.mFilename, mReport.mLine, mReport.mLineNumber,
|
||||
|
|
@ -2382,6 +2383,56 @@ WorkerPrivateParent<Derived>::GetDocument() const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
nsresult
|
||||
WorkerPrivateParent<Derived>::SetCSPFromHeaderValues(const nsACString& aCSPHeaderValue,
|
||||
const nsACString& aCSPReportOnlyHeaderValue)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mLoadInfo.mCSP);
|
||||
|
||||
NS_ConvertASCIItoUTF16 cspHeaderValue(aCSPHeaderValue);
|
||||
NS_ConvertASCIItoUTF16 cspROHeaderValue(aCSPReportOnlyHeaderValue);
|
||||
|
||||
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
||||
nsresult rv = mLoadInfo.mPrincipal->EnsureCSP(nullptr, getter_AddRefs(csp));
|
||||
if (!csp) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If there's a CSP header, apply it.
|
||||
if (!cspHeaderValue.IsEmpty()) {
|
||||
rv = CSP_AppendCSPFromHeader(csp, cspHeaderValue, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
// If there's a report-only CSP header, apply it.
|
||||
if (!cspROHeaderValue.IsEmpty()) {
|
||||
rv = CSP_AppendCSPFromHeader(csp, cspROHeaderValue, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Set evalAllowed, default value is set in GetAllowsEval
|
||||
bool evalAllowed = false;
|
||||
bool reportEvalViolations = false;
|
||||
rv = csp->GetAllowsEval(&reportEvalViolations, &evalAllowed);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Set ReferrerPolicy, default value is set in GetReferrerPolicy
|
||||
bool hasReferrerPolicy = false;
|
||||
uint32_t rp = mozilla::net::RP_Unset;
|
||||
rv = csp->GetReferrerPolicy(&rp, &hasReferrerPolicy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mLoadInfo.mCSP = csp;
|
||||
mLoadInfo.mEvalAllowed = evalAllowed;
|
||||
mLoadInfo.mReportCSPViolations = reportEvalViolations;
|
||||
|
||||
if (hasReferrerPolicy) {
|
||||
mLoadInfo.mReferrerPolicy = static_cast<net::ReferrerPolicy>(rp);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Can't use NS_IMPL_CYCLE_COLLECTION_CLASS(WorkerPrivateParent) because of the
|
||||
// templates.
|
||||
|
|
@ -3628,47 +3679,53 @@ WorkerPrivateParent<Derived>::SetBaseURI(nsIURI* aBaseURI)
|
|||
nsContentUtils::GetUTFOrigin(aBaseURI, mLocationInfo.mOrigin);
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
void
|
||||
WorkerPrivateParent<Derived>::SetPrincipal(nsIPrincipal* aPrincipal,
|
||||
nsILoadGroup* aLoadGroup)
|
||||
nsresult
|
||||
WorkerLoadInfo::SetPrincipalOnMainThread(nsIPrincipal* aPrincipal,
|
||||
nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(NS_LoadGroupMatchesPrincipal(aLoadGroup, aPrincipal));
|
||||
MOZ_ASSERT(!mLoadInfo.mPrincipalInfo);
|
||||
|
||||
mLoadInfo.mPrincipal = aPrincipal;
|
||||
mLoadInfo.mPrincipalIsSystem = nsContentUtils::IsSystemPrincipal(aPrincipal);
|
||||
mPrincipal = aPrincipal;
|
||||
mPrincipalIsSystem = nsContentUtils::IsSystemPrincipal(aPrincipal);
|
||||
|
||||
aPrincipal->GetCsp(getter_AddRefs(mLoadInfo.mCSP));
|
||||
nsresult rv = aPrincipal->GetCsp(getter_AddRefs(mCSP));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mLoadInfo.mCSP) {
|
||||
mLoadInfo.mCSP->GetAllowsEval(&mLoadInfo.mReportCSPViolations,
|
||||
&mLoadInfo.mEvalAllowed);
|
||||
if (mCSP) {
|
||||
mCSP->GetAllowsEval(&mReportCSPViolations, &mEvalAllowed);
|
||||
// Set ReferrerPolicy
|
||||
bool hasReferrerPolicy = false;
|
||||
uint32_t rp = mozilla::net::RP_Default;
|
||||
uint32_t rp = mozilla::net::RP_Unset;
|
||||
|
||||
nsresult rv = mLoadInfo.mCSP->GetReferrerPolicy(&rp, &hasReferrerPolicy);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
rv = mCSP->GetReferrerPolicy(&rp, &hasReferrerPolicy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (hasReferrerPolicy) {
|
||||
mLoadInfo.mReferrerPolicy = static_cast<net::ReferrerPolicy>(rp);
|
||||
mReferrerPolicy = static_cast<net::ReferrerPolicy>(rp);
|
||||
}
|
||||
} else {
|
||||
mLoadInfo.mEvalAllowed = true;
|
||||
mLoadInfo.mReportCSPViolations = false;
|
||||
mEvalAllowed = true;
|
||||
mReportCSPViolations = false;
|
||||
}
|
||||
|
||||
mLoadInfo.mLoadGroup = aLoadGroup;
|
||||
mLoadGroup = aLoadGroup;
|
||||
|
||||
mLoadInfo.mPrincipalInfo = new PrincipalInfo();
|
||||
mLoadInfo.mOriginAttributes = nsContentUtils::GetOriginAttributes(aLoadGroup);
|
||||
mPrincipalInfo = new PrincipalInfo();
|
||||
mOriginAttributes = nsContentUtils::GetOriginAttributes(aLoadGroup);
|
||||
|
||||
nsContentUtils::GetUTFOrigin(aPrincipal, mLoadInfo.mOrigin);
|
||||
rv = PrincipalToPrincipalInfo(aPrincipal, mPrincipalInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
PrincipalToPrincipalInfo(aPrincipal, mLoadInfo.mPrincipalInfo));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
nsresult
|
||||
WorkerPrivateParent<Derived>::SetPrincipalOnMainThread(nsIPrincipal* aPrincipal,
|
||||
nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
return mLoadInfo.SetPrincipalOnMainThread(aPrincipal, aLoadGroup);
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
|
|
@ -6679,7 +6736,7 @@ WorkerPrivate::GetOrCreateGlobalScope(JSContext* aCx)
|
|||
if (IsSharedWorker()) {
|
||||
globalScope = new SharedWorkerGlobalScope(this, WorkerName());
|
||||
} else if (IsServiceWorker()) {
|
||||
globalScope = new ServiceWorkerGlobalScope(this, WorkerName());
|
||||
globalScope = new ServiceWorkerGlobalScope(this, ServiceWorkerScope());
|
||||
} else {
|
||||
globalScope = new DedicatedWorkerGlobalScope(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue