Introduce new message sources for logging.

https://bugs.webkit.org/show_bug.cgi?id=110968

Patch by Dmitry Zvorygin <zvorygin@chromium.org> on 2013-03-06
Reviewed by Pavel Feldman.

Source/WebCore:

Added SecurityMessageSource, RenderingMessageSource, StorageMessageSource, AppCacheMessageSource, CSSMessageSource.
Changed some logging lines to contain more descriptive message source.

* Modules/webdatabase/DatabaseBase.cpp:
(WebCore::DatabaseBase::logErrorMessage):
* Modules/webdatabase/DatabaseManager.cpp:
(WebCore::DatabaseManager::logErrorMessage):
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::fail):
* bindings/ScriptControllerBase.cpp:
(WebCore::ScriptController::canExecuteScripts):
* css/MediaList.cpp:
(WebCore::addResolutionWarningMessageToConsole):
* dom/Document.cpp:
(WebCore::Document::processHttpEquiv):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::executeScript):
(WebCore::ScriptElement::notifyFinished):
* dom/ViewportArguments.cpp:
(WebCore::reportViewportWarning):
* html/HTMLFormControlElement.cpp:
(WebCore::shouldAutofocus):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::validateInteractively):
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::parseAttribute):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::getImageData):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::printWarningToConsole):
* html/parser/XSSAuditor.cpp:
(WebCore::XSSAuditor::init):
* html/parser/XSSAuditorDelegate.cpp:
(WebCore::XSSAuditorDelegate::didBlockScript):
* inspector/ConsoleMessage.cpp:
(WebCore::messageSourceValue):
* inspector/Inspector.json:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::submitForm):
(WebCore::FrameLoader::reportLocalLoadFailed):
(WebCore::createWindow):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::notifyFinished):
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::responseReceived):
* loader/MixedContentChecker.cpp:
(WebCore::MixedContentChecker::logWarning):
* loader/TextTrackLoader.cpp:
(WebCore::TextTrackLoader::corsPolicyPreventedLoad):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::abort):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::printAccessDeniedMessage):
* page/Console.cpp:
(WebCore::printMessageSourceAndLevelPrefix):
* page/ConsoleTypes.h:
* page/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::logToConsole):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchMessageEventWithOriginCheck):
* page/PointerLockController.cpp:
(WebCore::PointerLockController::requestPointerLock):
* svg/SVGDocumentExtensions.cpp:
(WebCore::reportMessage):

Source/WebKit/mac:

* WebCoreSupport/WebChromeClient.mm:
* WebView/WebUIDelegatePrivate.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@144949 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3be9f7f6
2013-03-06 Dmitry Zvorygin <zvorygin@chromium.org>
Introduce new message sources for logging.
https://bugs.webkit.org/show_bug.cgi?id=110968
Reviewed by Pavel Feldman.
Added SecurityMessageSource, RenderingMessageSource, StorageMessageSource, AppCacheMessageSource, CSSMessageSource.
Changed some logging lines to contain more descriptive message source.
* Modules/webdatabase/DatabaseBase.cpp:
(WebCore::DatabaseBase::logErrorMessage):
* Modules/webdatabase/DatabaseManager.cpp:
(WebCore::DatabaseManager::logErrorMessage):
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::fail):
* bindings/ScriptControllerBase.cpp:
(WebCore::ScriptController::canExecuteScripts):
* css/MediaList.cpp:
(WebCore::addResolutionWarningMessageToConsole):
* dom/Document.cpp:
(WebCore::Document::processHttpEquiv):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::executeScript):
(WebCore::ScriptElement::notifyFinished):
* dom/ViewportArguments.cpp:
(WebCore::reportViewportWarning):
* html/HTMLFormControlElement.cpp:
(WebCore::shouldAutofocus):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::validateInteractively):
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::parseAttribute):
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::getImageData):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::printWarningToConsole):
* html/parser/XSSAuditor.cpp:
(WebCore::XSSAuditor::init):
* html/parser/XSSAuditorDelegate.cpp:
(WebCore::XSSAuditorDelegate::didBlockScript):
* inspector/ConsoleMessage.cpp:
(WebCore::messageSourceValue):
* inspector/Inspector.json:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::submitForm):
(WebCore::FrameLoader::reportLocalLoadFailed):
(WebCore::createWindow):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::notifyFinished):
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::responseReceived):
* loader/MixedContentChecker.cpp:
(WebCore::MixedContentChecker::logWarning):
* loader/TextTrackLoader.cpp:
(WebCore::TextTrackLoader::corsPolicyPreventedLoad):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::abort):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::printAccessDeniedMessage):
* page/Console.cpp:
(WebCore::printMessageSourceAndLevelPrefix):
* page/ConsoleTypes.h:
* page/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::logToConsole):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchMessageEventWithOriginCheck):
* page/PointerLockController.cpp:
(WebCore::PointerLockController::requestPointerLock):
* svg/SVGDocumentExtensions.cpp:
(WebCore::reportMessage):
2013-03-06 Florin Malita <fmalita@chromium.org>
SVG pattern to pattern reference does not work if first pattern has a child node
......@@ -46,7 +46,7 @@ ScriptExecutionContext* DatabaseBase::scriptExecutionContext() const
void DatabaseBase::logErrorMessage(const String& message)
{
m_scriptExecutionContext->addConsoleMessage(OtherMessageSource, ErrorMessageLevel, message);
m_scriptExecutionContext->addConsoleMessage(StorageMessageSource, ErrorMessageLevel, message);
}
} // namespace WebCore
......
......@@ -430,7 +430,7 @@ void DatabaseManager::interruptAllDatabasesForContext(ScriptExecutionContext* co
void DatabaseManager::logErrorMessage(ScriptExecutionContext* context, const String& message)
{
context->addConsoleMessage(OtherMessageSource, ErrorMessageLevel, message);
context->addConsoleMessage(StorageMessageSource, ErrorMessageLevel, message);
}
} // namespace WebCore
......
......@@ -195,7 +195,7 @@ void WebSocketChannel::fail(const String& reason)
ASSERT(!m_suspended);
if (m_document) {
InspectorInstrumentation::didReceiveWebSocketFrameError(m_document, m_identifier, reason);
m_document->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "WebSocket connection to '" + m_handshake->url().elidedString() + "' failed: " + reason);
m_document->addConsoleMessage(NetworkMessageSource, ErrorMessageLevel, "WebSocket connection to '" + m_handshake->url().elidedString() + "' failed: " + reason);
}
// Hybi-10 specification explicitly states we must not continue to handle incoming data
......
......@@ -42,7 +42,7 @@ bool ScriptController::canExecuteScripts(ReasonForCallingCanExecuteScripts reaso
if (m_frame->document() && m_frame->document()->isSandboxed(SandboxScripts)) {
// FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
if (reason == AboutToExecuteScript)
m_frame->document()->addConsoleMessage(HTMLMessageSource, ErrorMessageLevel, "Blocked script execution in '" + m_frame->document()->url().elidedString() + "' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.");
m_frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked script execution in '" + m_frame->document()->url().elidedString() + "' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.");
return false;
}
......
......@@ -326,7 +326,7 @@ static void addResolutionWarningMessageToConsole(Document* document, const Strin
message.append(serializedExpression);
document->addConsoleMessage(HTMLMessageSource, DebugMessageLevel, message);
document->addConsoleMessage(CSSMessageSource, DebugMessageLevel, message);
}
void reportMediaQueryWarningIfNeeded(Document* document, const MediaQuerySet* mediaQuerySet)
......
......@@ -2874,7 +2874,7 @@ void Document::processHttpEquiv(const String& equiv, const String& content)
String message = "Refused to display '" + url().elidedString() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
frameLoader->stopAllLoaders();
frame->navigationScheduler()->scheduleLocationChange(securityOrigin(), blankURL(), String());
addConsoleMessage(JSMessageSource, ErrorMessageLevel, message, requestIdentifier);
addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, requestIdentifier);
}
}
} else if (equalIgnoringCase(equiv, "content-security-policy"))
......
......@@ -296,7 +296,7 @@ void ScriptElement::executeScript(const ScriptSourceCode& sourceCode)
#if ENABLE(NOSNIFF)
if (m_isExternalScript && m_cachedScript && !m_cachedScript->mimeTypeAllowedByNosniff()) {
m_element->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Refused to execute script from '" + m_cachedScript->url().elidedString() + "' because its MIME type ('" + m_cachedScript->mimeType() + "') is not executable, and strict MIME type checking is enabled.");
m_element->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Refused to execute script from '" + m_cachedScript->url().elidedString() + "' because its MIME type ('" + m_cachedScript->mimeType() + "') is not executable, and strict MIME type checking is enabled.");
return;
}
#endif
......
......@@ -449,7 +449,7 @@ void reportViewportWarning(Document* document, ViewportErrorCode errorCode, cons
message.append(" Note that ';' is not a separator in viewport values. The list should be comma-separated.");
// FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
document->addConsoleMessage(HTMLMessageSource, viewportErrorMessageLevel(errorCode), message);
document->addConsoleMessage(RenderingMessageSource, viewportErrorMessageLevel(errorCode), message);
}
} // namespace WebCore
......@@ -180,7 +180,7 @@ static bool shouldAutofocus(HTMLFormControlElement* element)
return false;
if (element->document()->isSandboxed(SandboxAutomaticFeatures)) {
// FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
element->document()->addConsoleMessage(HTMLMessageSource, ErrorMessageLevel, "Blocked autofocusing on a form control because the form's frame is sandboxed and the 'allow-scripts' permission is not set.");
element->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked autofocusing on a form control because the form's frame is sandboxed and the 'allow-scripts' permission is not set.");
return false;
}
if (element->hasAutofocused())
......
......@@ -261,7 +261,7 @@ bool HTMLFormElement::validateInteractively(Event* event)
continue;
String message("An invalid form control with name='%name' is not focusable.");
message.replace("%name", unhandledAssociatedElement->name());
document()->addConsoleMessage(HTMLMessageSource, ErrorMessageLevel, message);
document()->addConsoleMessage(RenderingMessageSource, ErrorMessageLevel, message);
}
}
return false;
......
......@@ -90,7 +90,7 @@ void HTMLIFrameElement::parseAttribute(const QualifiedName& name, const AtomicSt
String invalidTokens;
setSandboxFlags(value.isNull() ? SandboxNone : SecurityContext::parseSandboxPolicy(value, invalidTokens));
if (!invalidTokens.isNull())
document()->addConsoleMessage(HTMLMessageSource, ErrorMessageLevel, "Error while parsing the 'sandbox' attribute: " + invalidTokens);
document()->addConsoleMessage(OtherMessageSource, ErrorMessageLevel, "Error while parsing the 'sandbox' attribute: " + invalidTokens);
} else if (name == seamlessAttr) {
// If we're adding or removing the seamless attribute, we need to force the content document to recalculate its StyleResolver.
if (contentDocument())
......
......@@ -1867,7 +1867,7 @@ PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(ImageBuffer::Coordi
{
if (!canvas()->originClean()) {
DEFINE_STATIC_LOCAL(String, consoleMessage, (ASCIILiteral("Unable to get image data from canvas because the canvas has been tainted by cross-origin data.")));
canvas()->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, consoleMessage);
canvas()->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, consoleMessage);
ec = SECURITY_ERR;
return 0;
}
......
......@@ -5483,7 +5483,7 @@ void WebGLRenderingContext::printWarningToConsole(const String& message)
Document* document = canvas()->document();
if (!document)
return;
document->addConsoleMessage(HTMLMessageSource, WarningMessageLevel, message);
document->addConsoleMessage(RenderingMessageSource, WarningMessageLevel, message);
}
bool WebGLRenderingContext::validateFramebufferFuncParameters(const char* functionName, GC3Denum target, GC3Denum attachment)
......
......@@ -289,7 +289,7 @@ void XSSAuditor::init(Document* document)
}
}
if (xssProtectionHeader == ContentSecurityPolicy::ReflectedXSSInvalid)
document->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Error parsing header X-XSS-Protection: " + headerValue + ": " + errorDetails + " at character position " + String::format("%u", errorPosition) + ". The default protections will be applied.");
document->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Error parsing header X-XSS-Protection: " + headerValue + ": " + errorDetails + " at character position " + String::format("%u", errorPosition) + ". The default protections will be applied.");
m_xssProtection = combineXSSProtectionHeaderAndCSP(xssProtectionHeader, document->contentSecurityPolicy()->reflectedXSSDisposition());
m_reportURL = xssProtectionReportURL; // FIXME: Combine the two report URLs in some reasonable way.
......
......@@ -61,7 +61,7 @@ void XSSAuditorDelegate::didBlockScript(const XSSInfo& xssInfo)
// FIXME: Consider using a more helpful console message.
DEFINE_STATIC_LOCAL(String, consoleMessage, (ASCIILiteral("Refused to execute a JavaScript script. Source code of script found within request.\n")));
m_document->addConsoleMessage(JSMessageSource, ErrorMessageLevel, consoleMessage);
m_document->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, consoleMessage);
if (xssInfo.m_didBlockEntirePage)
m_document->frame()->loader()->stopAllLoaders();
......@@ -84,7 +84,7 @@ void XSSAuditorDelegate::didBlockScript(const XSSInfo& xssInfo)
}
if (xssInfo.m_didBlockEntirePage) {
m_document->addConsoleMessage(JSMessageSource, ErrorMessageLevel, String("Entire page will be blocked."));
m_document->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, String("Entire page will be blocked."));
m_document->frame()->navigationScheduler()->scheduleLocationChange(m_document->securityOrigin(), String("data:text/html,<p></p>"), blankURL());
}
}
......
......@@ -137,11 +137,15 @@ void ConsoleMessage::autogenerateMetadata(bool canGenerateCallStack, ScriptState
static TypeBuilder::Console::ConsoleMessage::Source::Enum messageSourceValue(MessageSource source)
{
switch (source) {
case HTMLMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Html;
case XMLMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Xml;
case JSMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Javascript;
case NetworkMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Network;
case ConsoleAPIMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Console_api;
case StorageMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Storage;
case AppCacheMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Appcache;
case RenderingMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Rendering;
case CSSMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Css;
case SecurityMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Security;
case OtherMessageSource: return TypeBuilder::Console::ConsoleMessage::Source::Other;
}
return TypeBuilder::Console::ConsoleMessage::Source::Other;
......
......@@ -768,8 +768,8 @@
"type": "object",
"description": "Console message.",
"properties": [
{ "name": "source", "type": "string", "enum": ["html", "wml", "xml", "javascript", "network", "console-api", "other"], "description": "Message source." },
{ "name": "level", "type": "string", "enum": ["tip", "log", "warning", "error", "debug"], "description": "Message severity." },
{ "name": "source", "type": "string", "enum": ["xml", "javascript", "network", "console-api", "storage", "appcache", "rendering", "css", "security", "other"], "description": "Message source." },
{ "name": "level", "type": "string", "enum": ["log", "warning", "error", "debug"], "description": "Message severity." },
{ "name": "text", "type": "string", "description": "Message text." },
{ "name": "type", "type": "string", "optional": true, "enum": ["log", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "timing", "profile", "profileEnd"], "description": "Console message type." },
{ "name": "url", "type": "string", "optional": true, "description": "URL of the message origin." },
......
......@@ -340,7 +340,7 @@ void FrameLoader::submitForm(PassRefPtr<FormSubmission> submission)
if (isDocumentSandboxed(m_frame, SandboxForms)) {
// FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
m_frame->document()->addConsoleMessage(HTMLMessageSource, ErrorMessageLevel, "Blocked form submission to '" + submission->action().elidedString() + "' because the form's frame is sandboxed and the 'allow-forms' permission is not set.");
m_frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked form submission to '" + submission->action().elidedString() + "' because the form's frame is sandboxed and the 'allow-forms' permission is not set.");
return;
}
......@@ -1414,7 +1414,7 @@ void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url)
if (!frame)
return;
frame->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Not allowed to load local resource: " + url);
frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Not allowed to load local resource: " + url);
}
const ResourceRequest& FrameLoader::initialRequest() const
......@@ -3367,7 +3367,7 @@ Frame* createWindow(Frame* openerFrame, Frame* lookupFrame, const FrameLoadReque
// Sandboxed frames cannot open new auxiliary browsing contexts.
if (isDocumentSandboxed(openerFrame, SandboxPopups)) {
// FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
openerFrame->document()->addConsoleMessage(HTMLMessageSource, ErrorMessageLevel, "Blocked opening '" + request.resourceRequest().url().elidedString() + "' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.");
openerFrame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked opening '" + request.resourceRequest().url().elidedString() + "' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.");
return 0;
}
......
......@@ -295,7 +295,7 @@ void ImageLoader::notifyFinished(CachedResource* resource)
errorEventSender().dispatchEventSoon(this);
DEFINE_STATIC_LOCAL(String, consoleMessage, (ASCIILiteral("Cross-origin image load denied by Cross-Origin Resource Sharing policy.")));
m_element->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, consoleMessage);
m_element->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, consoleMessage);
ASSERT(!m_hasPendingLoadEvent);
......
......@@ -411,7 +411,7 @@ void MainResourceLoader::responseReceived(CachedResource* resource, const Resour
if (frameLoader()->shouldInterruptLoadForXFrameOptions(content, r.url(), identifier())) {
InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_documentLoader->frame(), documentLoader(), identifier(), r);
String message = "Refused to display '" + r.url().elidedString() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
m_documentLoader->frame()->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message, identifier());
m_documentLoader->frame()->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, identifier());
cancel();
return;
......
......@@ -96,7 +96,7 @@ bool MixedContentChecker::canRunInsecureContent(SecurityOrigin* securityOrigin,
void MixedContentChecker::logWarning(bool allowed, const String& action, const KURL& target) const
{
String message = makeString((allowed ? "" : "[blocked] "), "The page at ", m_frame->document()->url().elidedString(), " ", action, " insecure content from ", target.elidedString(), ".\n");
m_frame->document()->addConsoleMessage(HTMLMessageSource, WarningMessageLevel, message);
m_frame->document()->addConsoleMessage(SecurityMessageSource, WarningMessageLevel, message);
}
} // namespace WebCore
......@@ -118,7 +118,7 @@ void TextTrackLoader::corsPolicyPreventedLoad()
{
DEFINE_STATIC_LOCAL(String, consoleMessage, (ASCIILiteral("Cross-origin text track load denied by Cross-Origin Resource Sharing policy.")));
Document* document = static_cast<Document*>(m_scriptExecutionContext);
document->addConsoleMessage(JSMessageSource, ErrorMessageLevel, consoleMessage);
document->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, consoleMessage);
m_state = Failed;
}
......
......@@ -475,7 +475,7 @@ void ApplicationCacheGroup::abort(Frame* frame)
if (m_completionType != None)
return;
frame->document()->addConsoleMessage(OtherMessageSource, DebugMessageLevel, "Application Cache download process was aborted.");
frame->document()->addConsoleMessage(NetworkMessageSource, DebugMessageLevel, "Application Cache download process was aborted.");
cacheUpdateFailed();
}
......
......@@ -662,7 +662,7 @@ void CachedResourceLoader::printAccessDeniedMessage(const KURL& url) const
else
message = "Unsafe attempt to load URL " + url.elidedString() + " from frame with URL " + m_document->url().elidedString() + ". Domains, protocols and ports must match.\n";
frame()->document()->addConsoleMessage(OtherMessageSource, ErrorMessageLevel, message);
frame()->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message);
}
void CachedResourceLoader::setAutoLoadImages(bool enable)
......
......@@ -88,9 +88,6 @@ static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel
{
const char* sourceString;
switch (source) {
case HTMLMessageSource:
sourceString = "HTML";
break;
case XMLMessageSource:
sourceString = "XML";
break;
......@@ -103,6 +100,21 @@ static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel
case ConsoleAPIMessageSource:
sourceString = "CONSOLEAPI";
break;
case StorageMessageSource:
sourceString = "STORAGE";
break;
case AppCacheMessageSource:
sourceString = "APPCACHE";
break;
case RenderingMessageSource:
sourceString = "RENDERING";
break;
case CSSMessageSource:
sourceString = "CSS";
break;
case SecurityMessageSource:
sourceString = "SECURITY";
break;
case OtherMessageSource:
sourceString = "OTHER";
break;
......
......@@ -29,11 +29,15 @@
namespace WebCore {
enum MessageSource {
HTMLMessageSource,
XMLMessageSource,
JSMessageSource,
NetworkMessageSource,
ConsoleAPIMessageSource,
StorageMessageSource,
AppCacheMessageSource,
RenderingMessageSource,
CSSMessageSource,
SecurityMessageSource,
OtherMessageSource,
};
......
......@@ -1815,7 +1815,7 @@ void ContentSecurityPolicy::reportMissingReportURI(const String& policy) const
void ContentSecurityPolicy::logToConsole(const String& message, const String& contextURL, const WTF::OrdinalNumber& contextLine, ScriptState* state) const
{
m_scriptExecutionContext->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message, contextURL, contextLine.oneBasedInt(), state);
m_scriptExecutionContext->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, contextURL, contextLine.oneBasedInt(), state);
}
void ContentSecurityPolicy::reportBlockedScriptExecutionToInspector(const String& directiveText) const
......
......@@ -884,7 +884,7 @@ void DOMWindow::dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTarg
if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrigin())) {
String message = "Unable to post message to " + intendedTargetOrigin->toString() +
". Recipient has origin " + document()->securityOrigin()->toString() + ".\n";
console()->addMessage(JSMessageSource, ErrorMessageLevel, message, stackTrace);
console()->addMessage(SecurityMessageSource, ErrorMessageLevel, message, stackTrace);
return;
}
}
......
......@@ -56,7 +56,7 @@ void PointerLockController::requestPointerLock(Element* target)
if (target->document()->isSandboxed(SandboxPointerLock)) {
// FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
target->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Blocked pointer lock on an element because the element's frame is sandboxed and the 'allow-pointer-lock' permission is not set.");
target->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked pointer lock on an element because the element's frame is sandboxed and the 'allow-pointer-lock' permission is not set.");
enqueueEvent(eventNames().webkitpointerlockerrorEvent, target);
return;
}
......
......@@ -135,7 +135,7 @@ void SVGDocumentExtensions::dispatchSVGLoadEventToOutermostSVGElements()
static void reportMessage(Document* document, MessageLevel level, const String& message)
{
if (document->frame())
document->addConsoleMessage(JSMessageSource, level, message);
document->addConsoleMessage(RenderingMessageSource, level, message);
}
void SVGDocumentExtensions::reportWarning(const String& message)
......
2013-03-06 Dmitry Zvorygin <zvorygin@chromium.org>
Introduce new message sources for logging.
https://bugs.webkit.org/show_bug.cgi?id=110968
Reviewed by Pavel Feldman.
* WebCoreSupport/WebChromeClient.mm:
* WebView/WebUIDelegatePrivate.h:
2013-03-05 Kent Tamura <tkent@chromium.org>
Rename WebCore/editing/visible_units.* to VisibleUnits.*
......
......@@ -90,11 +90,15 @@
#import "NetscapePluginHostManager.h"
#endif
NSString *WebConsoleMessageHTMLMessageSource = @"HTMLMessageSource";
NSString *WebConsoleMessageXMLMessageSource = @"XMLMessageSource";
NSString *WebConsoleMessageJSMessageSource = @"JSMessageSource";
NSString *WebConsoleMessageNetworkMessageSource = @"NetworkMessageSource";
NSString *WebConsoleMessageConsoleAPIMessageSource = @"ConsoleAPIMessageSource";
NSString *WebConsoleMessageStorageMessageSource = @"StorageMessageSource";
NSString *WebConsoleMessageAppCacheMessageSource = @"AppCacheMessageSource";
NSString *WebConsoleMessageRenderingMessageSource = @"RenderingMessageSource";
NSString *WebConsoleMessageCSSMessageSource = @"CSSMessageSource";
NSString *WebConsoleMessageSecurityMessageSource = @"SecurityMessageSource";
NSString *WebConsoleMessageOtherMessageSource = @"OtherMessageSource";
NSString *WebConsoleMessageDebugMessageLevel = @"DebugMessageLevel";
......@@ -329,8 +333,6 @@ void WebChromeClient::setResizable(bool b)
inline static NSString *stringForMessageSource(MessageSource source)
{
switch (source) {
case HTMLMessageSource:
return WebConsoleMessageHTMLMessageSource;
case XMLMessageSource:
return WebConsoleMessageXMLMessageSource;
case JSMessageSource:
......@@ -339,6 +341,16 @@ inline static NSString *stringForMessageSource(MessageSource source)
return WebConsoleMessageNetworkMessageSource;
case ConsoleAPIMessageSource:
return WebConsoleMessageConsoleAPIMessageSource;
case StorageMessageSource:
return WebConsoleMessageStorageMessageSource;
case AppCacheMessageSource:
return WebConsoleMessageAppCacheMessageSource;
case RenderingMessageSource:
return WebConsoleMessageRenderingMessageSource;
case CSSMessageSource:
return WebConsoleMessageCSSMessageSource;
case SecurityMessageSource:
return WebConsoleMessageSecurityMessageSource;
case OtherMessageSource:
return WebConsoleMessageOtherMessageSource;
}
......
......@@ -104,11 +104,15 @@ enum {
};
// Message Sources.
extern NSString *WebConsoleMessageHTMLMessageSource;
extern NSString *WebConsoleMessageXMLMessageSource;
extern NSString *WebConsoleMessageJSMessageSource;
extern NSString *WebConsoleMessageNetworkMessageSource;
extern NSString *WebConsoleMessageConsoleAPIMessageSource;
extern NSString *WebConsoleMessageStorageMessageSource;
extern NSString *WebConsoleMessageAppCacheMessageSource;
extern NSString *WebConsoleMessageRenderingMessageSource;
extern NSString *WebConsoleMessageCSSMessageSource;
extern NSString *WebConsoleMessageSecurityMessageSource;
extern NSString *WebConsoleMessageOtherMessageSource;
// Message Levels.
......@@ -143,7 +147,7 @@ extern NSString *WebConsoleMessageErrorMessageLevel;
@method webView:addMessageToConsole:withSource:
@param webView The WebView sending the delegate method.
@param message A dictionary representation of the console message.
@param source Where the message came from. See WebConsoleMessageHTMLMessageSource and other source types.
@param source Where the message came from. See WebConsoleMessageXMLMessageSource and other source types.
@discussion The dictionary contains the following keys:
<dl>
......@@ -155,8 +159,8 @@ extern NSString *WebConsoleMessageErrorMessageLevel;
<dd>If this came from a file, this is the URL to the file this message originates from.</dd>
<dt>MessageSource</dt>
<dd>
Where the message came from. HTML, XML, JavaScript, CSS, etc.
See WebConsoleMessageHTMLMessageSource and similar constants.
Where the message came from. XML, JavaScript, CSS, etc.
See WebConsoleMessageXMLMessageSource and similar constants.
</dd>
<dt>MessageLevel</dt>
<dd>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment