2011-03-11 Andrey Kosyakov <caseq@chromium.org>
authorcaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Mar 2011 09:28:38 +0000 (09:28 +0000)
committercaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Mar 2011 09:28:38 +0000 (09:28 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: resource load cancellation is reported to console as an error
        https://bugs.webkit.org/show_bug.cgi?id=55764

        - mark interruptionForPolicyChangeError as cancellation
        - do not log resource cancelation as an error
        - always push resource to front-end before console message, so front-end can use resource info while formatting message.

        * inspector/InspectorConsoleAgent.cpp:
        (WebCore::InspectorConsoleAgent::didFailLoading):
        * inspector/InspectorInstrumentation.cpp:
        (WebCore::InspectorInstrumentation::didReceiveResourceResponseImpl):
        (WebCore::InspectorInstrumentation::didFailLoadingImpl):
        * loader/MainResourceLoader.cpp:
        (WebCore::MainResourceLoader::stopLoadingForPolicyChange):

2011-03-11  Andrey Kosyakov  <caseq@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: resource load cancellation is reported to console as an error
        https://bugs.webkit.org/show_bug.cgi?id=55764

        * http/tests/inspector/console-resource-errors-expected.txt:
        * http/tests/inspector/console-resource-errors.html: Added test for lack of console messages during policy change (at download)
        * http/tests/inspector/console-xhr-logging-expected.txt:
        * http/tests/inspector/console-xhr-logging.html: Added test for reporting of cross-origin XHR errors.
        * http/tests/inspector/resources/empty.zip: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80832 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/console-resource-errors-expected.txt
LayoutTests/http/tests/inspector/console-resource-errors.html
LayoutTests/http/tests/inspector/console-xhr-logging-expected.txt
LayoutTests/http/tests/inspector/console-xhr-logging.html
LayoutTests/http/tests/inspector/resources/empty.zip [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorConsoleAgent.cpp
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/loader/MainResourceLoader.cpp

index 6c9393b..1249689 100644 (file)
@@ -1,3 +1,20 @@
+2011-03-11  Andrey Kosyakov  <caseq@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: resource load cancellation is reported to console as an error
+        https://bugs.webkit.org/show_bug.cgi?id=55764
+
+        - mark interruptionForPolicyChangeError as cancellation
+        - do not log resource cancelation as an error
+        - always push resource to front-end before console message, so front-end can use resource info while formatting message.
+
+        * http/tests/inspector/console-resource-errors-expected.txt:
+        * http/tests/inspector/console-resource-errors.html: Added test for lack of console messages during policy change (at download)
+        * http/tests/inspector/console-xhr-logging-expected.txt:
+        * http/tests/inspector/console-xhr-logging.html: Added test for reporting of cross-origin XHR errors.
+        * http/tests/inspector/resources/empty.zip: Added.
+
 2011-03-11  Ilya Sherman  <isherman@chromium.org>
 
         Reviewed by Kent Tamura.
index 6329bc5..12ddf8d 100644 (file)
@@ -1,5 +1,6 @@
  Tests that errors to load a resource cause error messages to be logged to console.
 
+ download
 Page reloaded.
 missing.cssGET http://127.0.0.1:8000/inspector/missing.css 404 (Not Found) console-message console-error-level
 non-existent-iframe.htmlGET http://127.0.0.1:8000/inspector/non-existent-iframe.html 404 (Not Found) console-message console-error-level
index b5dd330..2acec1c 100644 (file)
@@ -10,27 +10,49 @@ var xhr = new XMLHttpRequest();
 xhr.open("GET","non-existent-xhr", false);
 xhr.send(null);
 
+function performDownload()
+{
+    var a = document.body.getElementsByTagName("a")[0];
+    var event = document.createEvent("UIEvents");
+    event.initUIEvent("click", true, true, window, 1);
+    a.dispatchEvent(event);
+}
+
 function test()
 {
+    function onResource(event)
+    {
+        var resource = event.data;
+        if (/\/empty\.zip$/.test(resource.url)) {
+            InspectorTest.expandConsoleMessages();
+            InspectorTest.dumpConsoleMessagesWithClasses(true);
+            InspectorTest.completeTest();
+        }
+    }
+    function onMainResourceCommitLoad()
+    {
+        WebInspector.console.clearMessages();
+        WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, onResource, this);
+    }
+    WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.MainResourceCommitLoad, onMainResourceCommitLoad, this);
     InspectorTest.reloadPage(function() {
-        InspectorTest.expandConsoleMessages();
-        InspectorTest.dumpConsoleMessagesWithClasses(true);
-        InspectorTest.completeTest();
+        InspectorTest.evaluateInPageWithTimeout("performDownload();");
     });
 }
 
-
-
 </script>
 </head>
 
 <body onload="runTest()">
 <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>
 
+<iframe name="frame"></iframe>
+<a href="resources/empty.zip" target="frame">download</a>
 </body>
 </html>
index ce1c621..03cc387 100644 (file)
@@ -2,8 +2,12 @@ CONSOLE MESSAGE: line 10: sending a %s request to %s
 CONSOLE MESSAGE: line 10: sending a %s request to %s
 CONSOLE MESSAGE: line 10: sending a %s request to %s
 CONSOLE MESSAGE: line 10: sending a %s request to %s
+CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/inspector/resources/xhr-exists.html. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
 CONSOLE MESSAGE: line 10: sending a %s request to %s
 CONSOLE MESSAGE: line 10: sending a %s request to %s
+CONSOLE MESSAGE: line 10: sending a %s request to %s
+CONSOLE MESSAGE: line 10: sending a %s request to %s
+CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/inspector/resources/xhr-exists.html. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
 Tests that XMLHttpRequest Logging works when Enabled and doesn't show logs when Disabled.
 
 console-xhr-logging.html:10sending a GET request to resources/xhr-exists.html
@@ -13,8 +17,12 @@ xhr-does-not-exist.htmlGET http://127.0.0.1:8000/inspector/resources/xhr-does-no
 XHR finished loading: "http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html".
 console-xhr-logging.html:10sending a POST request to resources/post-target.cgi
 XHR finished loading: "http://127.0.0.1:8000/inspector/resources/post-target.cgi".
+console-xhr-logging.html:10sending a GET request to http://localhost:8000/inspector/resources/xhr-exists.html
+XMLHttpRequest cannot load http://localhost:8000/inspector/resources/xhr-exists.html. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
 console-xhr-logging.html:10sending a GET request to resources/xhr-exists.html
 console-xhr-logging.html:10sending a GET request to resources/xhr-does-not-exist.html
 xhr-does-not-exist.htmlGET http://127.0.0.1:8000/inspector/resources/xhr-does-not-exist.html 404 (Not Found)
 console-xhr-logging.html:10sending a POST request to resources/post-target.cgi
+console-xhr-logging.html:10sending a GET request to http://localhost:8000/inspector/resources/xhr-exists.html
+XMLHttpRequest cannot load http://localhost:8000/inspector/resources/xhr-exists.html. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
 
index 039aff5..c7bb039 100755 (executable)
@@ -21,6 +21,8 @@ function makeRequests()
     requestHelper("GET", "resources/xhr-does-not-exist.html");
     // 3. POST to a page.
     requestHelper("POST", "resources/post-target.cgi");
+    // 4. Cross-origin request
+    requestHelper("GET", "http://localhost:8000/inspector/resources/xhr-exists.html");
 }
 
 function test()
diff --git a/LayoutTests/http/tests/inspector/resources/empty.zip b/LayoutTests/http/tests/inspector/resources/empty.zip
new file mode 100644 (file)
index 0000000..15cb0ec
Binary files /dev/null and b/LayoutTests/http/tests/inspector/resources/empty.zip differ
index d598f6f..7451224 100644 (file)
@@ -1,3 +1,22 @@
+2011-03-11  Andrey Kosyakov  <caseq@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: resource load cancellation is reported to console as an error
+        https://bugs.webkit.org/show_bug.cgi?id=55764
+
+        - mark interruptionForPolicyChangeError as cancellation
+        - do not log resource cancelation as an error
+        - always push resource to front-end before console message, so front-end can use resource info while formatting message.
+
+        * inspector/InspectorConsoleAgent.cpp:
+        (WebCore::InspectorConsoleAgent::didFailLoading):
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didReceiveResourceResponseImpl):
+        (WebCore::InspectorInstrumentation::didFailLoadingImpl):
+        * loader/MainResourceLoader.cpp:
+        (WebCore::MainResourceLoader::stopLoadingForPolicyChange):
+
 2011-03-10  Alexander Pavlov  <apavlov@chromium.org>
 
         Reviewed by Yury Semikhatsky.
index 0379590..3b85e43 100644 (file)
@@ -205,7 +205,8 @@ void InspectorConsoleAgent::didFailLoading(unsigned long identifier, const Resou
 {
     if (!m_inspectorAgent->enabled())
         return;
-
+    if (error.isCancellation()) // Report failures only.
+        return;
     String message = "Failed to load resource";
     if (!error.localizedDescription().isEmpty())
         message += ": " + error.localizedDescription();
index 09b71c9..3f35008 100644 (file)
@@ -455,7 +455,7 @@ void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorIns
     if (InspectorAgent* inspectorAgent = inspectorAgentForFrame(loader->frame())) {
         if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(inspectorAgent))
             resourceAgent->didReceiveResponse(identifier, loader, response);
-        inspectorAgent->consoleAgent()->didReceiveResponse(identifier, response);
+        inspectorAgent->consoleAgent()->didReceiveResponse(identifier, response); // This should come AFTER resource notification, front-end relies on this.
     }
 }
 
@@ -475,11 +475,11 @@ void InspectorInstrumentation::didFinishLoadingImpl(InspectorAgent* inspectorAge
 
 void InspectorInstrumentation::didFailLoadingImpl(InspectorAgent* inspectorAgent, unsigned long identifier, const ResourceError& error)
 {
-    inspectorAgent->consoleAgent()->didFailLoading(identifier, error);
     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorAgent))
         timelineAgent->didFinishLoadingResource(identifier, true, 0);
     if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(inspectorAgent))
         resourceAgent->didFailLoading(identifier, error);
+    inspectorAgent->consoleAgent()->didFailLoading(identifier, error); // This should come AFTER resource notification, front-end relies on this.
 }
 
 void InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl(InspectorAgent* inspectorAgent, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
index c3c8d62..0cdbc21 100644 (file)
@@ -118,7 +118,9 @@ ResourceError MainResourceLoader::interruptionForPolicyChangeError() const
 
 void MainResourceLoader::stopLoadingForPolicyChange()
 {
-    cancel(interruptionForPolicyChangeError());
+    ResourceError error = interruptionForPolicyChangeError();
+    error.setIsCancellation(true);
+    cancel(error);
 }
 
 void MainResourceLoader::callContinueAfterNavigationPolicy(void* argument, const ResourceRequest& request, PassRefPtr<FormState>, bool shouldContinue)