Title: [119759] trunk
Revision
119759
Author
[email protected]
Date
2012-06-07 15:08:53 -0700 (Thu, 07 Jun 2012)

Log Message

Source/WebCore: Should fire error event for empty 404 script
https://bugs.webkit.org/show_bug.cgi?id=50589

Patch by Edaena Salinas Jasso <[email protected]> on 2012-06-07
Reviewed by Brady Eidson.

Tests:
http/tests/loading/fire-error-event-empty-404-script.html
http/tests/loading/fire-error-script-no-content-type.html

* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::didReceiveResponse): We should check for http status
codes here to stop depending on the response being non-empty.
(WebCore::SubresourceLoader::didReceiveData): Moved the http status check but
avoid messing with multipart responses.
(WebCore::SubresourceLoader::checkForHTTPStatusCodeError): Renamed from
errorLoadingResource for clarity.

* loader/SubresourceLoader.h:
* loader/cf/SubresourceLoaderCF.cpp:
(WebCore::SubresourceLoader::didReceiveDataArray):
Updated for errorLoadingResource renaming.

LayoutTests: Should fire error event for empty 404 script
https://bugs.webkit.org/show_bug.cgi?id=50589

Patch by Edaena Salinas Jasso <[email protected]> on 2012-06-07
Reviewed by Brady Eidson.

Based on a test by Ojan Vafai.

* http/tests/loading/fire-error-event-empty-404-script-expected.txt: Added.
* http/tests/loading/fire-error-event-empty-404-script.html: Added.
* http/tests/loading/fire-error-event-script-no-content-type-expected.txt: Added.
* http/tests/loading/fire-error-event-script-no-content-type.html: Added.
* http/tests/loading/resources/404-with-empty-body-no-content-type.cgi: Added.
* http/tests/loading/resources/404-with-empty-body.cgi: Added.
* http/tests/resources/network-simulator.php: Fixed to no longer return 404 error
when logging a request.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (119758 => 119759)


--- trunk/LayoutTests/ChangeLog	2012-06-07 22:08:32 UTC (rev 119758)
+++ trunk/LayoutTests/ChangeLog	2012-06-07 22:08:53 UTC (rev 119759)
@@ -1,3 +1,21 @@
+2012-06-07  Edaena Salinas Jasso  <[email protected]>
+
+        Should fire error event for empty 404 script
+        https://bugs.webkit.org/show_bug.cgi?id=50589
+
+        Reviewed by Brady Eidson.
+
+        Based on a test by Ojan Vafai.
+
+        * http/tests/loading/fire-error-event-empty-404-script-expected.txt: Added.
+        * http/tests/loading/fire-error-event-empty-404-script.html: Added.
+        * http/tests/loading/fire-error-event-script-no-content-type-expected.txt: Added.
+        * http/tests/loading/fire-error-event-script-no-content-type.html: Added.
+        * http/tests/loading/resources/404-with-empty-body-no-content-type.cgi: Added.
+        * http/tests/loading/resources/404-with-empty-body.cgi: Added.
+        * http/tests/resources/network-simulator.php: Fixed to no longer return 404 error
+        when logging a request.
+
 2012-06-07  Ojan Vafai  <[email protected]>
 
         fast/js/dfg-double-vote-fuzz.html fails on Chromium release.

Added: trunk/LayoutTests/http/tests/loading/fire-error-event-empty-404-script-expected.txt (0 => 119759)


--- trunk/LayoutTests/http/tests/loading/fire-error-event-empty-404-script-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/fire-error-event-empty-404-script-expected.txt	2012-06-07 22:08:53 UTC (rev 119759)
@@ -0,0 +1,10 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+Test for bug 50589: Fire an error event for empty 404 script.
+
+Should say SUCCESS:
+
+SUCCESS

Added: trunk/LayoutTests/http/tests/loading/fire-error-event-empty-404-script.html (0 => 119759)


--- trunk/LayoutTests/http/tests/loading/fire-error-event-empty-404-script.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/fire-error-event-empty-404-script.html	2012-06-07 22:08:53 UTC (rev 119759)
@@ -0,0 +1,16 @@
+<html>
+<body>
+<p>Test for <a href="" 50589</a>:
+Fire an error event for empty 404 script.</p>
+<p>Should say SUCCESS:</p>
+<p id=result></p>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+</script>
+<script
+  src=""
+  _onload_="document.getElementById('result').textContent = 'FAILURE'"
+  _onerror_="document.getElementById('result').textContent = 'SUCCESS'"></script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/loading/fire-error-event-script-no-content-type-expected.txt (0 => 119759)


--- trunk/LayoutTests/http/tests/loading/fire-error-event-script-no-content-type-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/fire-error-event-script-no-content-type-expected.txt	2012-06-07 22:08:53 UTC (rev 119759)
@@ -0,0 +1,10 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+Test for bug 50589: Fire an error event for empty 404 script with no content-type.
+
+Should say SUCCESS:
+
+SUCCESS

Added: trunk/LayoutTests/http/tests/loading/fire-error-event-script-no-content-type.html (0 => 119759)


--- trunk/LayoutTests/http/tests/loading/fire-error-event-script-no-content-type.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/fire-error-event-script-no-content-type.html	2012-06-07 22:08:53 UTC (rev 119759)
@@ -0,0 +1,16 @@
+<html>
+<body>
+<p>Test for <a href="" 50589</a>:
+Fire an error event for empty 404 script with no content-type.</p>
+<p>Should say SUCCESS:</p>
+<p id=result></p>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+</script>
+<script
+  src=""
+  _onload_="document.getElementById('result').textContent = 'FAILURE'"
+  _onerror_="document.getElementById('result').textContent = 'SUCCESS'"></script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/loading/resources/404-with-empty-body-no-content-type.cgi (0 => 119759)


--- trunk/LayoutTests/http/tests/loading/resources/404-with-empty-body-no-content-type.cgi	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resources/404-with-empty-body-no-content-type.cgi	2012-06-07 22:08:53 UTC (rev 119759)
@@ -0,0 +1,3 @@
+#!/usr/bin/perl -w
+
+print "Status: 404 Not Found\n\n";
Property changes on: trunk/LayoutTests/http/tests/loading/resources/404-with-empty-body-no-content-type.cgi
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/http/tests/loading/resources/404-with-empty-body.cgi (0 => 119759)


--- trunk/LayoutTests/http/tests/loading/resources/404-with-empty-body.cgi	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resources/404-with-empty-body.cgi	2012-06-07 22:08:53 UTC (rev 119759)
@@ -0,0 +1,4 @@
+#!/usr/bin/perl -w
+
+print "Status: 404 Not Found\n";
+print "Content-type: text/_javascript_\n\n";
Property changes on: trunk/LayoutTests/http/tests/loading/resources/404-with-empty-body.cgi
___________________________________________________________________

Added: svn:executable

Modified: trunk/LayoutTests/http/tests/resources/network-simulator.php (119758 => 119759)


--- trunk/LayoutTests/http/tests/resources/network-simulator.php	2012-06-07 22:08:32 UTC (rev 119758)
+++ trunk/LayoutTests/http/tests/resources/network-simulator.php	2012-06-07 22:08:53 UTC (rev 119759)
@@ -152,7 +152,6 @@
     $newData = "\n".$path;
     // Documentation says that appends are atomic.
     file_put_contents($resourceLogFile, $newData, FILE_APPEND);
-    generateResponse($path);
 }
 
 $stateFile = sys_get_temp_dir() . "/network-simulator-state";

Modified: trunk/Source/WebCore/ChangeLog (119758 => 119759)


--- trunk/Source/WebCore/ChangeLog	2012-06-07 22:08:32 UTC (rev 119758)
+++ trunk/Source/WebCore/ChangeLog	2012-06-07 22:08:53 UTC (rev 119759)
@@ -1,3 +1,27 @@
+2012-06-07  Edaena Salinas Jasso  <[email protected]>
+
+        Should fire error event for empty 404 script
+        https://bugs.webkit.org/show_bug.cgi?id=50589
+        
+        Reviewed by Brady Eidson.
+
+        Tests: 
+        http/tests/loading/fire-error-event-empty-404-script.html
+        http/tests/loading/fire-error-script-no-content-type.html
+
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::didReceiveResponse): We should check for http status 
+        codes here to stop depending on the response being non-empty.
+        (WebCore::SubresourceLoader::didReceiveData): Moved the http status check but
+        avoid messing with multipart responses.
+        (WebCore::SubresourceLoader::checkForHTTPStatusCodeError): Renamed from 
+        errorLoadingResource for clarity.
+
+        * loader/SubresourceLoader.h:
+        * loader/cf/SubresourceLoaderCF.cpp:
+        (WebCore::SubresourceLoader::didReceiveDataArray):
+        Updated for errorLoadingResource renaming.
+
 2012-06-07  Konrad Piascik  <[email protected]>
 
         [BlackBerry] Update PlayBook's User Agent String for Web Inspector

Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (119758 => 119759)


--- trunk/Source/WebCore/loader/SubresourceLoader.cpp	2012-06-07 22:08:32 UTC (rev 119758)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp	2012-06-07 22:08:53 UTC (rev 119759)
@@ -209,6 +209,8 @@
         m_documentLoader->subresourceLoaderFinishedLoadingOnePart(this);
         didFinishLoadingOnePart(0);
     }
+
+    checkForHTTPStatusCodeError();
 }
 
 void SubresourceLoader::didReceiveData(const char* data, int length, long long encodedDataLength, bool allAtOnce)
@@ -221,13 +223,13 @@
     RefPtr<SubresourceLoader> protect(this);
     ResourceLoader::didReceiveData(data, length, encodedDataLength, allAtOnce);
 
-    if (errorLoadingResource() || m_loadingMultipartContent)
+    if (m_loadingMultipartContent)
         return;
 
     sendDataToResource(data, length);
 }
 
-bool SubresourceLoader::errorLoadingResource()
+bool SubresourceLoader::checkForHTTPStatusCodeError()
 {
     if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnoreHTTPStatusCodeErrors())
         return false;

Modified: trunk/Source/WebCore/loader/SubresourceLoader.h (119758 => 119759)


--- trunk/Source/WebCore/loader/SubresourceLoader.h	2012-06-07 22:08:32 UTC (rev 119758)
+++ trunk/Source/WebCore/loader/SubresourceLoader.h	2012-06-07 22:08:53 UTC (rev 119759)
@@ -72,7 +72,7 @@
 #endif
     virtual void releaseResources();
 
-    bool errorLoadingResource();
+    bool checkForHTTPStatusCodeError();
     void sendDataToResource(const char*, int);
 
     enum SubresourceLoaderState {

Modified: trunk/Source/WebCore/loader/cf/SubresourceLoaderCF.cpp (119758 => 119759)


--- trunk/Source/WebCore/loader/cf/SubresourceLoaderCF.cpp	2012-06-07 22:08:32 UTC (rev 119758)
+++ trunk/Source/WebCore/loader/cf/SubresourceLoaderCF.cpp	2012-06-07 22:08:53 UTC (rev 119759)
@@ -36,7 +36,7 @@
 
     ResourceLoader::didReceiveDataArray(dataArray);
 
-    if (errorLoadingResource())
+    if (checkForHTTPStatusCodeError())
         return;
 
     // A subresource loader does not load multipart sections progressively.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to