- Revision
- 117246
- Author
- [email protected]
- Date
- 2012-05-16 02:46:18 -0700 (Wed, 16 May 2012)
Log Message
[BlackBerry] xhr request to non existent file response is 0 and not 404.
https://bugs.webkit.org/show_bug.cgi?id=86344
Patch by Jason Liu <[email protected]> on 2012-05-16
Reviewed by George Staikos.
Source/WebCore:
NetworkJob receives 404 for a XMLHttpRequest which calls open("HEAD", "notExist.html", true).
There are no data received because its method is HEAD.
This case should not be treated as a failure.
Add shouldNotifyClientFailed() to treat XMLHttpRequest as a special case.
XMLHttpRequest will fail when status code is smaller than zero.
If we use "GET" and receive 404 without body, NetworkJob won't go through failing code path, too.
So add http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html
to check this case.
Test: http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html
http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html
* platform/network/blackberry/NetworkJob.cpp:
(WebCore::NetworkJob::sendResponseIfNeeded):
LayoutTests:
* http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (117245 => 117246)
--- trunk/LayoutTests/ChangeLog 2012-05-16 09:43:44 UTC (rev 117245)
+++ trunk/LayoutTests/ChangeLog 2012-05-16 09:46:18 UTC (rev 117246)
@@ -1,3 +1,12 @@
+2012-05-16 Jason Liu <[email protected]>
+
+ [BlackBerry] xhr request to non existent file response is 0 and not 404.
+ https://bugs.webkit.org/show_bug.cgi?id=86344
+
+ Reviewed by George Staikos.
+
+ * http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html:
+
2012-05-15 Jocelyn Turcotte <[email protected]>
[Qt] Unreviewed gardening, unskip a fixed test
Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/status-404-without-body.php (0 => 117246)
--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/status-404-without-body.php (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/status-404-without-body.php 2012-05-16 09:46:18 UTC (rev 117246)
@@ -0,0 +1,4 @@
+<?php
+ header('http/1.1 404 Not Found');
+ exit();
+?>
Added: trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body-expected.txt (0 => 117246)
--- trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body-expected.txt 2012-05-16 09:46:18 UTC (rev 117246)
@@ -0,0 +1,3 @@
+This tests the readyState of a XMLHttpRequset which is sended with a "GET" method. And the response's status is 404 without body.
+
+PASS
Copied: trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html (from rev 117245, trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html) (0 => 117246)
--- trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html 2012-05-16 09:46:18 UTC (rev 117246)
@@ -0,0 +1,34 @@
+<html>
+<head>
+<script type="text/_javascript_">
+function loadXMLDoc() {
+
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ var res = "";
+ var xmlhttp = new XMLHttpRequest();
+ xmlhttp._onreadystatechange_ = function() {
+ if (xmlhttp.readyState) {
+ res = res + xmlhttp.readyState;
+ if(res == "124" && xmlhttp.status == 404) {
+ document.getElementById('result').innerText = "PASS";
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+ }
+ }
+
+ xmlhttp.open("GET", "resources/status-404-without-body.php", true);
+ xmlhttp.send();
+}
+</script>
+</head>
+<body _onload_="loadXMLDoc()">
+<p>This tests the readyState of a XMLHttpRequset which is sended with a "GET" method. And the response's status is 404 without body.</p>
+<p id="result">FAIL</p>
+</body>
+</html>
Modified: trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html (117245 => 117246)
--- trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html 2012-05-16 09:43:44 UTC (rev 117245)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html 2012-05-16 09:46:18 UTC (rev 117246)
@@ -14,7 +14,7 @@
xmlhttp._onreadystatechange_ = function() {
if (xmlhttp.readyState) {
res = res + xmlhttp.readyState;
- if(res == "124"){
+ if(res == "124" && xmlhttp.status == 404) {
document.getElementById('result').innerText = "PASS";
if (window.layoutTestController)
Modified: trunk/Source/WebCore/ChangeLog (117245 => 117246)
--- trunk/Source/WebCore/ChangeLog 2012-05-16 09:43:44 UTC (rev 117245)
+++ trunk/Source/WebCore/ChangeLog 2012-05-16 09:46:18 UTC (rev 117246)
@@ -1,3 +1,26 @@
+2012-05-16 Jason Liu <[email protected]>
+
+ [BlackBerry] xhr request to non existent file response is 0 and not 404.
+ https://bugs.webkit.org/show_bug.cgi?id=86344
+
+ Reviewed by George Staikos.
+
+ NetworkJob receives 404 for a XMLHttpRequest which calls open("HEAD", "notExist.html", true).
+ There are no data received because its method is HEAD.
+ This case should not be treated as a failure.
+
+ Add shouldNotifyClientFailed() to treat XMLHttpRequest as a special case.
+ XMLHttpRequest will fail when status code is smaller than zero.
+
+ If we use "GET" and receive 404 without body, NetworkJob won't go through failing code path, too.
+ So add http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html
+ to check this case.
+
+ Test: http/tests/xmlhttprequest/xmlhttprequest-check-head-readystate-for-404.html
+ http/tests/xmlhttprequest/xmlhttprequest-check-get-readystate-for-404-without-body.html
+ * platform/network/blackberry/NetworkJob.cpp:
+ (WebCore::NetworkJob::sendResponseIfNeeded):
+
2012-05-16 MORITA Hajime <[email protected]>
HasCustomWillOrDidRecalcStyleFlag and family should live in a bit.
Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp (117245 => 117246)
--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp 2012-05-16 09:43:44 UTC (rev 117245)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.cpp 2012-05-16 09:46:18 UTC (rev 117246)
@@ -449,7 +449,7 @@
else if (isUnauthorized(m_extendedStatusCode))
purgeCredentials();
- if (shouldNotifyClientFinished()) {
+ if (shouldReleaseClientResource()) {
if (isRedirect(m_extendedStatusCode) && (m_redirectCount >= s_redirectMaximum))
m_extendedStatusCode = BlackBerry::Platform::FilterStream::StatusTooManyRedirects;
@@ -457,7 +457,7 @@
if (isClientAvailable()) {
RecursionGuard guard(m_callingClient);
- if (isError(m_extendedStatusCode) && !m_dataReceived && m_handle->firstRequest().httpMethod() != "HEAD") {
+ if (shouldNotifyClientFailed()) {
String domain = m_extendedStatusCode < 0 ? ResourceError::platformErrorDomain : ResourceError::httpErrorDomain;
ResourceError error(domain, m_extendedStatusCode, m_response.url().string(), m_response.httpStatusText());
m_handle->client()->didFail(m_handle.get(), error);
@@ -476,7 +476,7 @@
m_multipartResponse = nullptr;
}
-bool NetworkJob::shouldNotifyClientFinished()
+bool NetworkJob::shouldReleaseClientResource()
{
if (m_redirectCount >= s_redirectMaximum)
return true;
@@ -490,6 +490,13 @@
return true;
}
+bool NetworkJob::shouldNotifyClientFailed() const
+{
+ if (m_handle->firstRequest().targetType() == ResourceRequest::TargetIsXHR)
+ return m_extendedStatusCode < 0;
+ return isError(m_extendedStatusCode) && !m_dataReceived;
+}
+
bool NetworkJob::retryAsFTPDirectory()
{
m_needsRetryAsFTPDirectory = false;
@@ -574,7 +581,7 @@
m_responseSent = true;
- if (isError(m_extendedStatusCode) && !m_dataReceived)
+ if (shouldNotifyClientFailed())
return;
String urlFilename;
Modified: trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h (117245 => 117246)
--- trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h 2012-05-16 09:43:44 UTC (rev 117245)
+++ trunk/Source/WebCore/platform/network/blackberry/NetworkJob.h 2012-05-16 09:46:18 UTC (rev 117246)
@@ -95,7 +95,8 @@
bool shouldSendClientData() const;
- bool shouldNotifyClientFinished();
+ bool shouldReleaseClientResource();
+ bool shouldNotifyClientFailed() const;
bool shouldDeferLoading() const
{
@@ -133,7 +134,7 @@
void purgeCredentials();
- bool isError(int statusCode)
+ bool isError(int statusCode) const
{
return statusCode < 0 || (400 <= statusCode && statusCode < 600);
}