Issue #2736 - Part 14: Make CSP-enabled available to workers.

This commit is contained in:
Moonchild 2025-05-13 16:35:35 +02:00 committed by roytam1
commit 53a6f6349d
5 changed files with 79 additions and 39 deletions

View file

@ -8980,6 +8980,25 @@ nsContentUtils::StreamsEnabled(JSContext* aCx, JSObject* aObj)
return workerPrivate->StreamsEnabled();
}
// static
bool
nsContentUtils::CSPEnabled(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("security.csp.enabled", true);
}
using namespace workers;
// Otherwise, check the pref via the WorkerPrivate
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->CSPEnabled();
}
// static
bool
nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel)