Commit e8bb8648 authored by eric@webkit.org's avatar eric@webkit.org
Browse files

2010-04-28 Andrey Kosyakov <caseq@chromium.org>

        Reviewed by Yury Semikhatsky.

        Log error message to inspector console if a resource fails to load.
        Moved console-tests.js to http tests. Added support for sorting
        console messages, in case order may vary.
        https://bugs.webkit.org/show_bug.cgi?id=37215

        * http/tests/inspector/console-resource-errors-expected.txt: Added.
        * http/tests/inspector/console-resource-errors.html: Added.
        * http/tests/inspector/console-tests.js: Added.
        (dumpConsoleMessages.callback):
        (dumpConsoleMessages):
        (dumpConsoleMessagesWithClasses.callback):
        (dumpConsoleMessagesWithClasses):
        (frontend_dumpConsoleMessages):
        * inspector/console-clear.html:
        * inspector/console-dir.html:
        * inspector/console-dirxml.html:
        * inspector/console-format-collections-expected.txt:
        * inspector/console-format-collections.html:
        * inspector/console-format.html:
        * inspector/console-log-before-inspector-open.html:
        * inspector/console-tests.html:
        * inspector/console-tests.js: Removed.
        * platform/mac-tiger/http/tests/inspector: Added.
        * platform/mac-tiger/http/tests/inspector/console-resource-errors-expected.txt: Added.
2010-04-28  Andrey Kosyakov  <caseq@chromium.org>

        Reviewed by Yury Semikhatsky.

        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: http/tests/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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 00f16c11
2010-04-28 Andrey Kosyakov <caseq@chromium.org>
Reviewed by Yury Semikhatsky.
Log error message to inspector console if a resource fails to load.
Moved console-tests.js to http tests. Added support for sorting
console messages, in case order may vary.
https://bugs.webkit.org/show_bug.cgi?id=37215
* http/tests/inspector/console-resource-errors-expected.txt: Added.
* http/tests/inspector/console-resource-errors.html: Added.
* http/tests/inspector/console-tests.js: Added.
(dumpConsoleMessages.callback):
(dumpConsoleMessages):
(dumpConsoleMessagesWithClasses.callback):
(dumpConsoleMessagesWithClasses):
(frontend_dumpConsoleMessages):
* inspector/console-clear.html:
* inspector/console-dir.html:
* inspector/console-dirxml.html:
* inspector/console-format-collections-expected.txt:
* inspector/console-format-collections.html:
* inspector/console-format.html:
* inspector/console-log-before-inspector-open.html:
* inspector/console-tests.html:
* inspector/console-tests.js: Removed.
* platform/mac-tiger/http/tests/inspector: Added.
* platform/mac-tiger/http/tests/inspector/console-resource-errors-expected.txt: Added.
2010-04-28 Sheriff Bot <webkit.review.bot@gmail.com>
 
Unreviewed, rolling out r58313.
......
Tests that errors to load a resource cause error messages to be logged to console.
missing.cssFailed to load resource: the server responded with a status of 404 (Not Found) console-message console-other-source console-error-level
non-existent-iframe.htmlFailed to load resource: the server responded with a status of 404 (Not Found) console-message console-other-source console-error-level
non-existent-script.jsFailed to load resource: the server responded with a status of 404 (Not Found) console-message console-other-source console-error-level
non-existent-xhrFailed to load resource: the server responded with a status of 404 (Not Found) console-message console-other-source console-error-level
<html>
<head>
<script src="console-tests.js"></script>
<script src="inspector-test.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(true);
}
</script>
</head>
<body onload="onload()">
<p>
<script src="non-existent-script.js"></script>
<iframe src="non-existent-iframe.html"></iframe>
Tests that errors to load a resource cause error messages to be logged to console.
</p>
</body>
</html>
// Inspected Page functions.
function dumpConsoleMessages(noNotifyDone) {
function callback(result)
{
for (var i = 0; i < result.length; ++i)
output(result[i].text);
if (!noNotifyDone)
notifyDone();
}
evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
}
function dumpConsoleMessagesWithClasses(sortMessages) {
function callback(result)
{
var messages = [];
for (var i = 0; i < result.length; ++i)
messages.push(result[i].text + " " + result[i].clazz);
if (sortMessages)
messages.sort();
for (var i = 0; i < messages.length; ++i)
output(messages[i]);
notifyDone();
}
evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
}
// Frontend functions.
function frontend_dumpConsoleMessages()
{
var result = [];
var messages = WebInspector.console.messages;
for (var i = 0; i < messages.length; ++i) {
var element = messages[i].toMessageElement();
result.push({ text: element.textContent.replace(/\u200b/g, ""), clazz: element.getAttribute("class")});
}
return result;
}
// Inspected Page functions.
function dumpConsoleMessages(noNotifyDone) {
function callback(result)
{
for (var i = 0; i < result.length; ++i)
output(result[i].text);
if (!noNotifyDone)
notifyDone();
}
evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
}
function dumpConsoleMessagesWithClasses(sortMessages) {
function callback(result)
{
var messages = [];
for (var i = 0; i < result.length; ++i)
messages.push(result[i].text + " " + result[i].clazz);
if (sortMessages)
messages.sort();
for (var i = 0; i < messages.length; ++i)
output(messages[i]);
notifyDone();
}
evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
}
// Frontend functions.
function frontend_dumpConsoleMessages()
{
var result = [];
var messages = WebInspector.console.messages;
for (var i = 0; i < messages.length; ++i) {
var element = messages[i].toMessageElement();
result.push({ text: element.textContent.replace(/\u200b/g, ""), clazz: element.getAttribute("class")});
}
return result;
}
// Inspected Page functions.
function dumpConsoleMessages(noNotifyDone) {
function callback(result)
{
for (var i = 0; i < result.length; ++i)
output(result[i].text);
if (!noNotifyDone)
notifyDone();
}
evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
}
function dumpConsoleMessagesWithClasses(sortMessages) {
function callback(result)
{
var messages = [];
for (var i = 0; i < result.length; ++i)
messages.push(result[i].text + " " + result[i].clazz);
if (sortMessages)
messages.sort();
for (var i = 0; i < messages.length; ++i)
output(messages[i]);
notifyDone();
}
evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
}
// Frontend functions.
function frontend_dumpConsoleMessages()
{
var result = [];
var messages = WebInspector.console.messages;
for (var i = 0; i < messages.length; ++i) {
var element = messages[i].toMessageElement();
result.push({ text: element.textContent.replace(/\u200b/g, ""), clazz: element.getAttribute("class")});
}
return result;
}
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="console-tests.js"></script>
<script src="../http/tests/inspector/console-tests.js"></script>
<script>
function doit()
......
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="console-tests.js"></script>
<script src="../http/tests/inspector/console-tests.js"></script>
<script>
function doit()
......
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="console-tests.js"></script>
<script src="../http/tests/inspector/console-tests.js"></script>
<script>
function doit()
......
......@@ -8,9 +8,9 @@ CONSOLE MESSAGE: line 41: 1,2,
Tests that console nicely formats HTML Collections and NodeLists.
console-format-collections.html:15[<select id="sel" name="sel">…</select>]
console-format-collections.html:19[<script src="../http/tests/inspector/inspector-test.js"></script>, <script src="console-tests.js"></script>, <script>…</script>]
console-format-collections.html:19[<script src="../http/tests/inspector/inspector-test.js"></script>, <script src="../http/tests/inspector/console-tests.js"></script>, <script>…</script>]
console-format-collections.html:23[<option value="1">one</option>, <option value="2">two</option>]
console-format-collections.html:27[<html>…</html>, <head>…</head>, <script src="../http/tests/inspector/inspector-test.js"></script>, <script src="console-tests.js"></script>, <script>…</script>, <body onload="onload()">…</body>, <p> Tests that console nicely formats HTML Collections and NodeLists. </p>, <div style="display:none">…</div>, <form id="f">…</form>, <select id="sel" name="sel">…</select>, <option value="1">one</option>, <option value="2">two</option>, <input type="radio" name="x" value="x1">, <input type="radio" name="x" value="x2">, <div id="output"></div>]
console-format-collections.html:27[<html>…</html>, <head>…</head>, <script src="../http/tests/inspector/inspector-test.js"></script>, <script src="../http/tests/inspector/console-tests.js"></script>, <script>…</script>, <body onload="onload()">…</body>, <p> Tests that console nicely formats HTML Collections and NodeLists. </p>, <div style="display:none">…</div>, <form id="f">…</form>, <select id="sel" name="sel">…</select>, <option value="1">one</option>, <option value="2">two</option>, <input type="radio" name="x" value="x1">, <input type="radio" name="x" value="x2">, <div id="output"></div>]
console-format-collections.html:31[<select id="sel" name="sel">…</select>, <input type="radio" name="x" value="x1">, <input type="radio" name="x" value="x2">]
console-format-collections.html:35[<input type="radio" name="x" value="x1">, <input type="radio" name="x" value="x2">]
console-format-collections.html:41[1, Array]
......
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="console-tests.js"></script>
<script src="../http/tests/inspector/console-tests.js"></script>
<script>
function doit()
......
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="console-tests.js"></script>
<script src="../http/tests/inspector/console-tests.js"></script>
<script>
// Global Values
......
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="console-tests.js"></script>
<script src="../http/tests/inspector/console-tests.js"></script>
<script>
console.log('log');
......
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script src="console-tests.js"></script>
<script src="../http/tests/inspector/console-tests.js"></script>
<script>
function doit()
......
// Inspected Page functions.
function dumpConsoleMessages(noNotifyDone) {
function callback(result)
{
for (var i = 0; i < result.length; ++i)
output(result[i].text);
if (!noNotifyDone)
notifyDone();
}
evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
}
function dumpConsoleMessagesWithClasses() {
function callback(result)
{
for (var i = 0; i < result.length; ++i)
output(result[i].text + " " + result[i].clazz);
notifyDone();
}
evaluateInWebInspector("frontend_dumpConsoleMessages", callback);
}
// Frontend functions.
function frontend_dumpConsoleMessages()
{
var result = [];
var messages = WebInspector.console.messages;
for (var i = 0; i < messages.length; ++i) {
var element = messages[i].toMessageElement();
result.push({ text: element.textContent.replace(/\u200b/g, ""), clazz: element.getAttribute("class")});
}
return result;
}
Tests that errors to load a resource cause error messages to be logged to console.
missing.cssFailed to load resource: the server responded with a status of 404 (OK) console-message console-other-source console-error-level
non-existent-iframe.htmlFailed to load resource: the server responded with a status of 404 (OK) console-message console-other-source console-error-level
non-existent-script.jsFailed to load resource: the server responded with a status of 404 (OK) console-message console-other-source console-error-level
non-existent-xhrFailed to load resource: the server responded with a status of 404 (OK) console-message console-other-source console-error-level
2010-04-28 Andrey Kosyakov <caseq@chromium.org>
Reviewed by Yury Semikhatsky.
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: http/tests/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-28 Yury Semikhatsky <yurys@chromium.org>
 
Reviewed by Pavel Feldman.
......@@ -894,15 +894,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)
......@@ -933,11 +937,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;
......
......@@ -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)
......
......@@ -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();
......
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