Skip to content

Commit

Permalink
2010-04-14 Andrey Kosyakov <caseq@chromium.ru>
Browse files Browse the repository at this point in the history
        Reviewed by Timothy Hatcher.

        Log error message to inspector console if a resource fails to load.
        Disable checking of mime-type consistency for failed resources.
        https://bugs.webkit.org/show_bug.cgi?id=37215

        * inspector/console-resource-errors-expected.txt: Added.
        * inspector/console-resource-errors.html: Added.
2010-04-14  Andrey Kosyakov  <caseq@chromium.ru>

        Reviewed by Timothy Hatcher.

        Log error message to inspector console if a resource fails to load.
        Disable checking of mime-type consistency for failed resources.
        https://bugs.webkit.org/show_bug.cgi?id=37215

        Test: inspector/console-resource-errors.html

        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::didReceiveResponse):
        (WebCore::InspectorController::didFailLoading):
        * inspector/front-end/Resource.js:
        (WebInspector.Resource.prototype._mimeTypeIsConsistentWithType):
        * inspector/front-end/ResourcesPanel.js:
        (WebInspector.ResourcesPanel.prototype.recreateViewForResourceIfNeeded):

Canonical link: https://commits.webkit.org/48897@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@57609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eseidel committed Apr 14, 2010
1 parent d122b0d commit 6c7abdf
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 11 deletions.
11 changes: 11 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
2010-04-14 Andrey Kosyakov <caseq@chromium.ru>

Reviewed by Timothy Hatcher.

Log error message to inspector console if a resource fails to load.
Disable checking of mime-type consistency for failed resources.
https://bugs.webkit.org/show_bug.cgi?id=37215

* inspector/console-resource-errors-expected.txt: Added.
* inspector/console-resource-errors.html: Added.

2010-04-14 Alejandro G. Castro <alex@igalia.com>

Rubber-stamped by Xan Lopez.
Expand Down
6 changes: 6 additions & 0 deletions LayoutTests/inspector/console-resource-errors-expected.txt
@@ -0,0 +1,6 @@
Tests that errors to load a resource cause error messages to be logged to console.

missing.cssFailed to load resource: file doesn’t exist console-message console-other-source console-error-level
non-existent-script.jsFailed to load resource: file doesn’t exist console-message console-other-source console-error-level
non-esitent-iframe.htmlFailed to load resource: file doesn’t exist console-message console-other-source console-error-level

29 changes: 29 additions & 0 deletions LayoutTests/inspector/console-resource-errors.html
@@ -0,0 +1,29 @@
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="console-tests.js"></script>

<link rel="stylesheet" type="text/css" href="missing.css">

<script>
function doit()
{
var xhr = new XMLHttpRequest();
xhr.open("GET","non-existent-xhr", false);
xhr.send(null);
dumpConsoleMessagesWithClasses();
}

</script>
</head>

<body onload="onload()">
<p>
<script src="non-existent-script.js"></script>
<iframe src="non-esitent-iframe.html"></iframe>

Tests that errors to load a resource cause error messages to be logged to console.
</p>

</body>
</html>
18 changes: 18 additions & 0 deletions WebCore/ChangeLog
@@ -1,3 +1,21 @@
2010-04-14 Andrey Kosyakov <caseq@chromium.ru>

Reviewed by Timothy Hatcher.

Log error message to inspector console if a resource fails to load.
Disable checking of mime-type consistency for failed resources.
https://bugs.webkit.org/show_bug.cgi?id=37215

Test: inspector/console-resource-errors.html

* inspector/InspectorController.cpp:
(WebCore::InspectorController::didReceiveResponse):
(WebCore::InspectorController::didFailLoading):
* inspector/front-end/Resource.js:
(WebInspector.Resource.prototype._mimeTypeIsConsistentWithType):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype.recreateViewForResourceIfNeeded):

2010-04-14 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r57599.
Expand Down
25 changes: 17 additions & 8 deletions WebCore/inspector/InspectorController.cpp
Expand Up @@ -892,15 +892,19 @@ void InspectorController::willSendRequest(unsigned long identifier, const Resour

void InspectorController::didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
{
RefPtr<InspectorResource> resource = getTrackedResource(identifier);
if (!resource)
return;
if (RefPtr<InspectorResource> resource = getTrackedResource(identifier)) {
resource->updateResponse(response);
resource->markResponseReceivedTime();

resource->updateResponse(response);
resource->markResponseReceivedTime();
if (resource != m_mainResource && m_frontend)
resource->updateScriptObject(m_frontend.get());
}
if (response.httpStatusCode() >= 400) {
// The ugly code below is due to that String::format() is not utf8-safe at the moment.
String message = String::format("Failed to load resource: the server responded with a status of %u (", response.httpStatusCode()) + response.httpStatusText() + ")";

if (resource != m_mainResource && m_frontend)
resource->updateScriptObject(m_frontend.get());
addMessageToConsole(OtherMessageSource, LogMessageType, ErrorMessageLevel, message, 0, response.url().string());
}
}

void InspectorController::didReceiveContentLength(unsigned long identifier, int lengthReceived)
Expand Down Expand Up @@ -931,11 +935,16 @@ void InspectorController::didFinishLoading(unsigned long identifier)
resource->updateScriptObject(m_frontend.get());
}

void InspectorController::didFailLoading(unsigned long identifier, const ResourceError& /*error*/)
void InspectorController::didFailLoading(unsigned long identifier, const ResourceError& error)
{
if (m_timelineAgent)
m_timelineAgent->didFinishLoadingResource(identifier, true);

String message = "Failed to load resource";
if (!error.localizedDescription().isEmpty())
message += ": " + error.localizedDescription();
addMessageToConsole(OtherMessageSource, LogMessageType, ErrorMessageLevel, message, 0, error.failingURL());

RefPtr<InspectorResource> resource = getTrackedResource(identifier);
if (!resource)
return;
Expand Down
6 changes: 6 additions & 0 deletions WebCore/inspector/front-end/Resource.js
Expand Up @@ -536,6 +536,12 @@ WebInspector.Resource.prototype = {

_mimeTypeIsConsistentWithType: function()
{
// If status is an error, content is likely to be of an inconsistent type,
// as it's going to be an error message. We do not want to emit a warning
// for this, though, as this will already be reported as resource loading failure.
if (this.statusCode >= 400)
return true;

if (typeof this.type === "undefined"
|| this.type === WebInspector.Resource.Type.Other
|| this.type === WebInspector.Resource.Type.XHR)
Expand Down
3 changes: 0 additions & 3 deletions WebCore/inspector/front-end/ResourcesPanel.js
Expand Up @@ -443,9 +443,6 @@ WebInspector.ResourcesPanel.prototype = {
if (newView.__proto__ === resource._resourcesView.__proto__)
return;

resource.warnings = 0;
resource.errors = 0;

if (!this.currentQuery && resource._itemsTreeElement)
resource._itemsTreeElement.updateErrorsAndWarnings();

Expand Down

0 comments on commit 6c7abdf

Please sign in to comment.