diff --git a/dom/security/nsContentSecurityManager.cpp b/dom/security/nsContentSecurityManager.cpp index 6cf82cc73875..aa004c02fad2 100644 --- a/dom/security/nsContentSecurityManager.cpp +++ b/dom/security/nsContentSecurityManager.cpp @@ -105,6 +105,14 @@ DoCORSChecks(nsIChannel* aChannel, nsILoadInfo* aLoadInfo, nsCOMPtr& aInAndOutListener) { MOZ_RELEASE_ASSERT(aInAndOutListener, "can not perform CORS checks without a listener"); + + // No need to set up CORS if TriggeringPrincipal is the SystemPrincipal. + // For example, allow user stylesheets to load XBL from external files + // without requiring CORS. + if (nsContentUtils::IsSystemPrincipal(aLoadInfo->TriggeringPrincipal())) { + return NS_OK; + } + nsIPrincipal* loadingPrincipal = aLoadInfo->LoadingPrincipal(); RefPtr corsListener = new nsCORSListenerProxy(aInAndOutListener, @@ -476,10 +484,11 @@ nsContentSecurityManager::CheckChannel(nsIChannel* aChannel) return NS_OK; } - // Allow the load if TriggeringPrincipal is the SystemPrincipal which - // is e.g. necessary to allow user user stylesheets to load XBL from - // external files. - if (nsContentUtils::IsSystemPrincipal(loadInfo->TriggeringPrincipal())) { + // Allow subresource loads if TriggeringPrincipal is the SystemPrincipal. + // For example, allow user stylesheets to load XBL from external files. + if (nsContentUtils::IsSystemPrincipal(loadInfo->TriggeringPrincipal()) && + loadInfo->GetExternalContentPolicyType() != nsIContentPolicy::TYPE_DOCUMENT && + loadInfo->GetExternalContentPolicyType() != nsIContentPolicy::TYPE_SUBDOCUMENT) { return NS_OK; }