diff --git a/caps/src/nsPrincipal.cpp b/caps/src/nsPrincipal.cpp index be7449fff440..d592e8955efa 100644 --- a/caps/src/nsPrincipal.cpp +++ b/caps/src/nsPrincipal.cpp @@ -442,8 +442,6 @@ nsPrincipal::GetExtendedOrigin(nsACString& aExtendedOrigin) NS_IMETHODIMP nsPrincipal::GetAppStatus(uint16_t* aAppStatus) { - MOZ_ASSERT(mAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID); - *aAppStatus = GetAppStatus(); return NS_OK; } @@ -569,8 +567,8 @@ nsPrincipal::Write(nsIObjectOutputStream* aStream) uint16_t nsPrincipal::GetAppStatus() { - MOZ_ASSERT(mAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID); - + NS_WARN_IF_FALSE(mAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID, + "Asking for app status on a principal with an unknown app id"); // Installed apps have a valid app id (not NO_APP_ID or UNKNOWN_APP_ID) // and they are not inside a mozbrowser. if (mAppId == nsIScriptSecurityManager::NO_APP_ID || diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 27d8138589ec..4b4f32001823 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2550,32 +2550,23 @@ nsDocument::InitCSP(nsIChannel* aChannel) nsIPrincipal* principal = NodePrincipal(); - bool unknownAppId; - uint16_t appStatus = nsIPrincipal::APP_STATUS_NOT_INSTALLED; - nsAutoString appManifestCSP; - if (NS_SUCCEEDED(principal->GetUnknownAppId(&unknownAppId)) && - !unknownAppId && - NS_SUCCEEDED(principal->GetAppStatus(&appStatus))) { - applyAppDefaultCSP = ( appStatus == nsIPrincipal::APP_STATUS_PRIVILEGED || - appStatus == nsIPrincipal::APP_STATUS_CERTIFIED); + uint16_t appStatus = principal->GetAppStatus(); + applyAppDefaultCSP = appStatus == nsIPrincipal::APP_STATUS_PRIVILEGED || + appStatus == nsIPrincipal::APP_STATUS_CERTIFIED; - if (appStatus != nsIPrincipal::APP_STATUS_NOT_INSTALLED) { - nsCOMPtr appsService = do_GetService(APPS_SERVICE_CONTRACTID); - if (appsService) { - uint32_t appId = 0; - if (NS_SUCCEEDED(principal->GetAppId(&appId))) { - appsService->GetCSPByLocalId(appId, appManifestCSP); - if (!appManifestCSP.IsEmpty()) { - applyAppManifestCSP = true; - } + nsAutoString appManifestCSP; + if (appStatus != nsIPrincipal::APP_STATUS_NOT_INSTALLED) { + nsCOMPtr appsService = do_GetService(APPS_SERVICE_CONTRACTID); + if (appsService) { + uint32_t appId = 0; + if (NS_SUCCEEDED(principal->GetAppId(&appId))) { + appsService->GetCSPByLocalId(appId, appManifestCSP); + if (!appManifestCSP.IsEmpty()) { + applyAppManifestCSP = true; } } } } -#ifdef PR_LOGGING - else - PR_LOG(gCspPRLog, PR_LOG_DEBUG, ("Failed to get app status from principal")); -#endif // If there's no CSP to apply, go ahead and return early if (!applyAppDefaultCSP &&