mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
ported dependency of "Bug 1174307 - Add some internal content policy types for the purpose of reflecting them on RequestContex", some part may already in the tree:
- Bug 1175114 - Translate the content policy type obtained in CSPService::AsyncOnChannelRedirect to an external one before invoking the content policy implementation; r=smaug - Bug 1175122 - Add more assertions to the in-tree content policy implementations to ensure that they receive external content policy types; r=baku - Bug 1178339 - Account for service workers separately in WorkerDomainInfo; r=nsm
This commit is contained in:
@@ -249,6 +249,9 @@ CSPService::ShouldProcess(uint32_t aContentType,
|
||||
nsIPrincipal *aRequestPrincipal,
|
||||
int16_t *aDecision)
|
||||
{
|
||||
MOZ_ASSERT(aContentType == nsContentUtils::InternalContentPolicyTypeToExternal(aContentType),
|
||||
"We should only see external content policy types here.");
|
||||
|
||||
if (!aContentLocation)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -306,7 +309,8 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
|
||||
nsCOMPtr<nsIURI> originalUri;
|
||||
rv = oldChannel->GetOriginalURI(getter_AddRefs(originalUri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsContentPolicyType policyType = loadInfo->InternalContentPolicyType();
|
||||
nsContentPolicyType policyType =
|
||||
nsContentUtils::InternalContentPolicyTypeToExternal(loadInfo->InternalContentPolicyType());
|
||||
|
||||
int16_t aDecision = nsIContentPolicy::ACCEPT;
|
||||
csp->ShouldLoad(policyType, // load type per nsIContentPolicy (uint32_t)
|
||||
|
||||
@@ -1498,6 +1498,9 @@ RuntimeService::RegisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
else if (parent) {
|
||||
domainInfo->mChildWorkerCount++;
|
||||
}
|
||||
else if (isServiceWorker) {
|
||||
domainInfo->mActiveServiceWorkers.AppendElement(aWorkerPrivate);
|
||||
}
|
||||
else {
|
||||
domainInfo->mActiveWorkers.AppendElement(aWorkerPrivate);
|
||||
}
|
||||
@@ -1602,12 +1605,17 @@ RuntimeService::UnregisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
domainInfo->mQueuedWorkers.RemoveElementAt(index);
|
||||
}
|
||||
else if (parent) {
|
||||
NS_ASSERTION(domainInfo->mChildWorkerCount, "Must be non-zero!");
|
||||
MOZ_ASSERT(domainInfo->mChildWorkerCount, "Must be non-zero!");
|
||||
domainInfo->mChildWorkerCount--;
|
||||
}
|
||||
else if (aWorkerPrivate->IsServiceWorker()) {
|
||||
MOZ_ASSERT(domainInfo->mActiveServiceWorkers.Contains(aWorkerPrivate),
|
||||
"Don't know about this worker!");
|
||||
domainInfo->mActiveServiceWorkers.RemoveElement(aWorkerPrivate);
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(domainInfo->mActiveWorkers.Contains(aWorkerPrivate),
|
||||
"Don't know about this worker!");
|
||||
MOZ_ASSERT(domainInfo->mActiveWorkers.Contains(aWorkerPrivate),
|
||||
"Don't know about this worker!");
|
||||
domainInfo->mActiveWorkers.RemoveElement(aWorkerPrivate);
|
||||
}
|
||||
|
||||
@@ -1641,6 +1649,9 @@ RuntimeService::UnregisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
||||
if (queuedWorker->GetParent()) {
|
||||
domainInfo->mChildWorkerCount++;
|
||||
}
|
||||
else if (queuedWorker->IsServiceWorker()) {
|
||||
domainInfo->mActiveServiceWorkers.AppendElement(queuedWorker);
|
||||
}
|
||||
else {
|
||||
domainInfo->mActiveWorkers.AppendElement(queuedWorker);
|
||||
}
|
||||
@@ -2215,12 +2226,17 @@ RuntimeService::AddAllTopLevelWorkersToArray(const nsACString& aKey,
|
||||
|
||||
#ifdef DEBUG
|
||||
for (uint32_t index = 0; index < aData->mActiveWorkers.Length(); index++) {
|
||||
NS_ASSERTION(!aData->mActiveWorkers[index]->GetParent(),
|
||||
"Shouldn't have a parent in this list!");
|
||||
MOZ_ASSERT(!aData->mActiveWorkers[index]->GetParent(),
|
||||
"Shouldn't have a parent in this list!");
|
||||
}
|
||||
for (uint32_t index = 0; index < aData->mActiveServiceWorkers.Length(); index++) {
|
||||
MOZ_ASSERT(!aData->mActiveServiceWorkers[index]->GetParent(),
|
||||
"Shouldn't have a parent in this list!");
|
||||
}
|
||||
#endif
|
||||
|
||||
array->AppendElements(aData->mActiveWorkers);
|
||||
array->AppendElements(aData->mActiveServiceWorkers);
|
||||
|
||||
// These might not be top-level workers...
|
||||
for (uint32_t index = 0; index < aData->mQueuedWorkers.Length(); index++) {
|
||||
|
||||
@@ -43,6 +43,7 @@ class RuntimeService final : public nsIObserver
|
||||
{
|
||||
nsCString mDomain;
|
||||
nsTArray<WorkerPrivate*> mActiveWorkers;
|
||||
nsTArray<WorkerPrivate*> mActiveServiceWorkers;
|
||||
nsTArray<WorkerPrivate*> mQueuedWorkers;
|
||||
nsClassHashtable<nsCStringHashKey, SharedWorkerInfo> mSharedWorkerInfos;
|
||||
uint32_t mChildWorkerCount;
|
||||
@@ -54,7 +55,9 @@ class RuntimeService final : public nsIObserver
|
||||
uint32_t
|
||||
ActiveWorkerCount() const
|
||||
{
|
||||
return mActiveWorkers.Length() + mChildWorkerCount;
|
||||
return mActiveWorkers.Length() +
|
||||
mActiveServiceWorkers.Length() +
|
||||
mChildWorkerCount;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
// Possible behavior pref values
|
||||
// Those map to the nsIPermissionManager values where possible
|
||||
|
||||
Reference in New Issue
Block a user