Bug 897913 part 1. Don't assert that app id exists when asked for app status; just claim not installed if there is no app id. r=sicking

This commit is contained in:
Boris Zbarsky 2013-08-07 17:40:00 -04:00
parent 42d2829264
commit 146cff469c
2 changed files with 14 additions and 25 deletions

View File

@ -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 ||

View File

@ -2550,15 +2550,11 @@ 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;
nsAutoString appManifestCSP;
if (appStatus != nsIPrincipal::APP_STATUS_NOT_INSTALLED) {
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
if (appsService) {
@ -2571,11 +2567,6 @@ nsDocument::InitCSP(nsIChannel* aChannel)
}
}
}
}
#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 &&