Bug 1092055 - Show security messages for subresources. r=mcmanus

This commit is contained in:
Mark Goodwin 2015-02-09 07:04:00 -05:00
Родитель 7413eecfda
Коммит c0c1f9286c
1 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -16,6 +16,7 @@
#include "nsICachingChannel.h" #include "nsICachingChannel.h"
#include "nsIPrincipal.h" #include "nsIPrincipal.h"
#include "nsIScriptError.h"
#include "nsISeekableStream.h" #include "nsISeekableStream.h"
#include "nsITimedChannel.h" #include "nsITimedChannel.h"
#include "nsIEncodedChannel.h" #include "nsIEncodedChannel.h"
@ -1672,6 +1673,39 @@ HttpBaseChannel::AddSecurityMessage(const nsAString &aMessageTag,
message->SetTag(aMessageTag); message->SetTag(aMessageTag);
message->SetCategory(aMessageCategory); message->SetCategory(aMessageCategory);
mSecurityConsoleMessages.AppendElement(message); mSecurityConsoleMessages.AppendElement(message);
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (!console) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsILoadInfo> loadInfo;
GetLoadInfo(getter_AddRefs(loadInfo));
if (!loadInfo) {
return NS_ERROR_FAILURE;
}
uint32_t innerWindowID = loadInfo->GetInnerWindowID();
nsXPIDLString errorText;
rv = nsContentUtils::GetLocalizedString(
nsContentUtils::eSECURITY_PROPERTIES,
NS_ConvertUTF16toUTF8(aMessageTag).get(),
errorText);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString spec;
if (mURI) {
mURI->GetSpec(spec);
}
nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
error->InitWithWindowID(errorText, NS_ConvertUTF8toUTF16(spec),
EmptyString(), 0, 0, nsIScriptError::warningFlag,
NS_ConvertUTF16toUTF8(aMessageCategory),
innerWindowID);
console->LogMessage(error);
return NS_OK; return NS_OK;
} }