Diff
Modified: branches/safari-602-branch/LayoutTests/ChangeLog (207204 => 207205)
--- branches/safari-602-branch/LayoutTests/ChangeLog 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/LayoutTests/ChangeLog 2016-10-12 08:41:31 UTC (rev 207205)
@@ -1,5 +1,19 @@
2016-10-12 Matthew Hanson <matthew_han...@apple.com>
+ Merge r205190. rdar://problem/28545010
+
+ 2016-08-30 Youenn Fablet <you...@apple.com>
+
+ [Fetch API] Blob not found URL should result in a network error
+ https://bugs.webkit.org/show_bug.cgi?id=161381
+
+ Reviewed by Sam Weinig.
+
+ * fast/files/apply-blob-url-to-xhr-expected.txt:
+ * fast/files/workers/worker-apply-blob-url-to-xhr-expected.txt:
+
+2016-10-12 Matthew Hanson <matthew_han...@apple.com>
+
Merge r204266. rdar://problem/28216261
2016-08-08 John Wilander <wilan...@apple.com>
Modified: branches/safari-602-branch/LayoutTests/fast/files/apply-blob-url-to-xhr-expected.txt (207204 => 207205)
--- branches/safari-602-branch/LayoutTests/fast/files/apply-blob-url-to-xhr-expected.txt 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/LayoutTests/fast/files/apply-blob-url-to-xhr-expected.txt 2016-10-12 08:41:31 UTC (rev 207205)
@@ -5,7 +5,6 @@
Test that XMLHttpRequest POST fails.
Received exception 19: NetworkError
Test that XMLHttpRequest GET fails after the blob URL is revoked.
-Status: 404
-Response:
+Received exception 19: NetworkError
DONE
Modified: branches/safari-602-branch/LayoutTests/fast/files/workers/worker-apply-blob-url-to-xhr-expected.txt (207204 => 207205)
--- branches/safari-602-branch/LayoutTests/fast/files/workers/worker-apply-blob-url-to-xhr-expected.txt 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/LayoutTests/fast/files/workers/worker-apply-blob-url-to-xhr-expected.txt 2016-10-12 08:41:31 UTC (rev 207205)
@@ -5,7 +5,6 @@
Test that XMLHttpRequest POST fails.
Received exception 19: NetworkError
Test that XMLHttpRequest GET fails after the blob URL is revoked.
-Status: 404
-Response:
+Received exception 19: NetworkError
DONE
Modified: branches/safari-602-branch/LayoutTests/imported/w3c/ChangeLog (207204 => 207205)
--- branches/safari-602-branch/LayoutTests/imported/w3c/ChangeLog 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/LayoutTests/imported/w3c/ChangeLog 2016-10-12 08:41:31 UTC (rev 207205)
@@ -1,3 +1,21 @@
+2016-10-12 Matthew Hanson <matthew_han...@apple.com>
+
+ Merge r205190. rdar://problem/28545010
+
+ 2016-08-30 Youenn Fablet <you...@apple.com>
+
+ [Fetch API] Blob not found URL should result in a network error
+ https://bugs.webkit.org/show_bug.cgi?id=161381
+
+ Reviewed by Sam Weinig.
+
+ * web-platform-tests/fetch/api/basic/scheme-blob-expected.txt:
+ * web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt:
+ * web-platform-tests/fetch/api/basic/scheme-blob-worker.html:
+ * web-platform-tests/fetch/api/basic/scheme-blob.html:
+ * web-platform-tests/fetch/api/basic/scheme-blob.js:
+ (invalidRequestMethods.forEach):
+
2016-07-18 Youenn Fablet <you...@apple.com>
[Streams API] ReadableStream should throw a RangeError in case of NaN highWaterMark
Modified: branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt (207204 => 207205)
--- branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt 2016-10-12 08:41:31 UTC (rev 207205)
@@ -1,6 +1,6 @@
PASS Fetching [GET] URL.createObjectURL(blob) is OK
-PASS Fetching [GET] blob:http://www.localhost:8800/ is KO
+PASS Fetching [GET] not found blob URL is KO
PASS Fetching [POST] URL.createObjectURL(blob) is KO
PASS Fetching [OPTIONS] URL.createObjectURL(blob) is KO
PASS Fetching [HEAD] URL.createObjectURL(blob) is KO
Modified: branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt (207204 => 207205)
--- branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt 2016-10-12 08:41:31 UTC (rev 207205)
@@ -1,6 +1,6 @@
PASS Fetching [GET] URL.createObjectURL(blob) is OK
-PASS Fetching [GET] blob:http://www.localhost:8800/ is KO
+PASS Fetching [GET] not found blob URL is KO
PASS Fetching [POST] URL.createObjectURL(blob) is KO
PASS Fetching [OPTIONS] URL.createObjectURL(blob) is KO
PASS Fetching [HEAD] URL.createObjectURL(blob) is KO
Modified: branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker.html (207204 => 207205)
--- branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker.html 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker.html 2016-10-12 08:41:31 UTC (rev 207205)
@@ -11,7 +11,7 @@
</head>
<body>
<script>
- fetch_tests_from_worker(new Worker("scheme-blob.js?pipe=sub"));
+ fetch_tests_from_worker(new Worker("scheme-blob.js"));
</script>
</body>
-</html>
\ No newline at end of file
+</html>
Modified: branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.html (207204 => 207205)
--- branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.html 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.html 2016-10-12 08:41:31 UTC (rev 207205)
@@ -11,6 +11,6 @@
</head>
<body>
<script src=""
- <script src=""
+ <script src=""
</body>
-</html>
\ No newline at end of file
+</html>
Modified: branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js (207204 => 207205)
--- branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js 2016-10-12 08:41:31 UTC (rev 207205)
@@ -30,8 +30,9 @@
}
var blob2 = new Blob(["Blob's data"], { "type" : "text/plain" });
-checkKoUrl("blob:http://{{domains[www]}}:{{ports[http][0]}}/", "GET",
- "Fetching [GET] blob:http://{{domains[www]}}:{{ports[http][0]}}/ is KO");
+var blob2URL = URL.createObjectURL(blob2);
+checkKoUrl(blob2URL + "notfoundblob", "GET",
+ "Fetching [GET] not found blob URL is KO");
var invalidRequestMethods = [
"POST",
@@ -42,7 +43,7 @@
"INVALID",
];
invalidRequestMethods.forEach(function(method) {
- checkKoUrl(URL.createObjectURL(blob2), method, "Fetching [" + method + "] URL.createObjectURL(blob) is KO");
+ checkKoUrl(blob2URL, method, "Fetching [" + method + "] URL.createObjectURL(blob) is KO");
});
done();
Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (207204 => 207205)
--- branches/safari-602-branch/Source/WebCore/ChangeLog 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog 2016-10-12 08:41:31 UTC (rev 207205)
@@ -1,5 +1,45 @@
2016-10-12 Matthew Hanson <matthew_han...@apple.com>
+ Merge r205190. rdar://problem/28545010
+
+ 2016-08-30 Youenn Fablet <you...@apple.com>
+
+ [Fetch API] Blob not found URL should result in a network error
+ https://bugs.webkit.org/show_bug.cgi?id=161381
+
+ Reviewed by Sam Weinig.
+
+ Covered by rebased and updated tests.
+
+ Raising a network error if no blob can be found from the URL.
+ It is no longer notified by a 404 response.
+
+ Updated FileReaderLoader to generate the correct exception.
+
+ Made some clean-up in the code, in particular adding an enum class for BlobResourceHandle errors.
+
+ * fileapi/FileReaderLoader.cpp:
+ (WebCore::FileReaderLoader::didFail):
+ (WebCore::FileReaderLoader::toErrorCode):
+ (WebCore::FileReaderLoader::httpStatusCodeToErrorCode):
+ * fileapi/FileReaderLoader.h:
+ * platform/network/BlobResourceHandle.cpp:
+ (WebCore::BlobResourceHandle::loadResourceSynchronously):
+ (WebCore::BlobResourceHandle::doStart):
+ (WebCore::BlobResourceHandle::didGetSize):
+ (WebCore::BlobResourceHandle::readSync):
+ (WebCore::BlobResourceHandle::readFileSync):
+ (WebCore::BlobResourceHandle::readAsync):
+ (WebCore::BlobResourceHandle::didOpen):
+ (WebCore::BlobResourceHandle::didRead):
+ (WebCore::BlobResourceHandle::failed):
+ (WebCore::BlobResourceHandle::notifyResponse):
+ (WebCore::BlobResourceHandle::notifyResponseOnError):
+ (WebCore::BlobResourceHandle::notifyFail):
+ * platform/network/BlobResourceHandle.h:
+
+2016-10-12 Matthew Hanson <matthew_han...@apple.com>
+
Merge r204631. rdar://problem/28481427
2016-08-19 Chris Dumez <cdu...@apple.com>
Modified: branches/safari-602-branch/Source/WebCore/fileapi/FileReaderLoader.cpp (207204 => 207205)
--- branches/safari-602-branch/Source/WebCore/fileapi/FileReaderLoader.cpp 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/Source/WebCore/fileapi/FileReaderLoader.cpp 2016-10-12 08:41:31 UTC (rev 207205)
@@ -36,6 +36,7 @@
#include "BlobURL.h"
#include "FileReaderLoaderClient.h"
#include "HTTPHeaderNames.h"
+#include "ResourceError.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include "ScriptExecutionContext.h"
@@ -227,13 +228,13 @@
m_client->didFinishLoading();
}
-void FileReaderLoader::didFail(const ResourceError&)
+void FileReaderLoader::didFail(const ResourceError& error)
{
// If we're aborting, do not proceed with normal error handling since it is covered in aborting code.
if (m_errorCode == FileError::ABORT_ERR)
return;
- failed(FileError::NOT_READABLE_ERR);
+ failed(toErrorCode(static_cast<BlobResourceHandle::Error>(error.errorCode())));
}
void FileReaderLoader::failed(int errorCode)
@@ -244,13 +245,21 @@
m_client->didFail(m_errorCode);
}
+FileError::ErrorCode FileReaderLoader::toErrorCode(BlobResourceHandle::Error error)
+{
+ switch (error) {
+ case BlobResourceHandle::Error::NotFoundError:
+ return FileError::NOT_FOUND_ERR;
+ default:
+ return FileError::NOT_READABLE_ERR;
+ }
+}
+
FileError::ErrorCode FileReaderLoader::httpStatusCodeToErrorCode(int httpStatusCode)
{
switch (httpStatusCode) {
case 403:
return FileError::SECURITY_ERR;
- case 404:
- return FileError::NOT_FOUND_ERR;
default:
return FileError::NOT_READABLE_ERR;
}
Modified: branches/safari-602-branch/Source/WebCore/fileapi/FileReaderLoader.h (207204 => 207205)
--- branches/safari-602-branch/Source/WebCore/fileapi/FileReaderLoader.h 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/Source/WebCore/fileapi/FileReaderLoader.h 2016-10-12 08:41:31 UTC (rev 207205)
@@ -31,6 +31,7 @@
#ifndef FileReaderLoader_h
#define FileReaderLoader_h
+#include "BlobResourceHandle.h"
#include "FileError.h"
#include "URL.h"
#include "TextEncoding.h"
@@ -92,6 +93,7 @@
bool isCompleted() const;
static FileError::ErrorCode httpStatusCodeToErrorCode(int);
+ static FileError::ErrorCode toErrorCode(BlobResourceHandle::Error);
ReadType m_readType;
FileReaderLoaderClient* m_client;
Modified: branches/safari-602-branch/Source/WebCore/platform/network/BlobResourceHandle.cpp (207204 => 207205)
--- branches/safari-602-branch/Source/WebCore/platform/network/BlobResourceHandle.cpp 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/Source/WebCore/platform/network/BlobResourceHandle.cpp 2016-10-12 08:41:31 UTC (rev 207205)
@@ -55,24 +55,15 @@
static const int httpOK = 200;
static const int httpPartialContent = 206;
static const int httpNotAllowed = 403;
-static const int httpNotFound = 404;
static const int httpRequestedRangeNotSatisfiable = 416;
static const int httpInternalError = 500;
static const char* httpOKText = "OK";
static const char* httpPartialContentText = "Partial Content";
static const char* httpNotAllowedText = "Not Allowed";
-static const char* httpNotFoundText = "Not Found";
static const char* httpRequestedRangeNotSatisfiableText = "Requested Range Not Satisfiable";
static const char* httpInternalErrorText = "Internal Server Error";
static const char* const webKitBlobResourceDomain = "WebKitBlobResource";
-enum {
- notFoundError = 1,
- securityError = 2,
- rangeError = 3,
- notReadableError = 4,
- methodNotAllowed = 5
-};
///////////////////////////////////////////////////////////////////////////////
// BlobResourceSynchronousLoader
@@ -103,7 +94,7 @@
{
// We cannot handle the size that is more than maximum integer.
if (response.expectedContentLength() > INT_MAX) {
- m_error = ResourceError(webKitBlobResourceDomain, notReadableError, response.url(), "File is too large");
+ m_error = ResourceError(webKitBlobResourceDomain, static_cast<int>(BlobResourceHandle::Error::NotReadableError), response.url(), "File is too large");
return;
}
@@ -132,7 +123,7 @@
void BlobResourceHandle::loadResourceSynchronously(BlobData* blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data)
{
if (!equalLettersIgnoringASCIICase(request.httpMethod(), "get")) {
- error = ResourceError(webKitBlobResourceDomain, methodNotAllowed, response.url(), "Request method must be GET");
+ error = ResourceError(webKitBlobResourceDomain, static_cast<int>(Error::MethodNotAllowed), response.url(), "Request method must be GET");
return;
}
@@ -188,18 +179,17 @@
ASSERT(isMainThread());
// Do not continue if the request is aborted or an error occurs.
- if (m_aborted || m_errorCode)
+ if (erroredOrAborted())
return;
if (!equalLettersIgnoringASCIICase(firstRequest().httpMethod(), "get")) {
- notifyFail(methodNotAllowed);
+ notifyFail(Error::MethodNotAllowed);
return;
}
// If the blob data is not found, fail now.
if (!m_blobData) {
- m_errorCode = notFoundError;
- notifyResponse();
+ notifyFail(Error::NotFoundError);
return;
}
@@ -206,7 +196,7 @@
// Parse the "Range" header we care about.
String range = firstRequest().httpHeaderField(HTTPHeaderName::Range);
if (!range.isEmpty() && !parseRange(range, m_rangeOffset, m_rangeEnd, m_rangeSuffixLength)) {
- m_errorCode = rangeError;
+ m_errorCode = Error::RangeError;
notifyResponse();
return;
}
@@ -215,7 +205,7 @@
getSizeForNext();
else {
Ref<BlobResourceHandle> protectedThis(*this); // getSizeForNext calls the client
- for (size_t i = 0; i < m_blobData->items().size() && !m_aborted && !m_errorCode; ++i)
+ for (size_t i = 0; i < m_blobData->items().size() && !erroredOrAborted(); ++i)
getSizeForNext();
notifyResponse();
}
@@ -261,13 +251,12 @@
ASSERT(isMainThread());
// Do not continue if the request is aborted or an error occurs.
- if (m_aborted || m_errorCode)
+ if (erroredOrAborted())
return;
// If the size is -1, it means the file has been moved or changed. Fail now.
if (size == -1) {
- m_errorCode = notFoundError;
- notifyResponse();
+ notifyFail(Error::NotFoundError);
return;
}
@@ -329,13 +318,13 @@
int remaining = length;
while (remaining) {
// Do not continue if the request is aborted or an error occurs.
- if (m_aborted || m_errorCode)
+ if (erroredOrAborted())
break;
// If there is no more remaining data to read, we are done.
if (!m_totalRemainingSize || m_readItemCount >= m_blobData->items().size())
break;
-
+
const BlobDataItem& item = m_blobData->items().at(m_readItemCount);
int bytesRead = 0;
if (item.type() == BlobDataItem::Type::Data)
@@ -352,7 +341,7 @@
}
int result;
- if (m_aborted || m_errorCode)
+ if (erroredOrAborted())
result = -1;
else
result = length - remaining;
@@ -401,7 +390,7 @@
bool success = m_stream->openForRead(item.file()->path(), item.offset() + m_currentItemReadSize, bytesToRead);
m_currentItemReadSize = 0;
if (!success) {
- m_errorCode = notReadableError;
+ m_errorCode = Error::NotReadableError;
return 0;
}
@@ -410,7 +399,7 @@
int bytesRead = m_stream->read(buf, length);
if (bytesRead < 0) {
- m_errorCode = notReadableError;
+ m_errorCode = Error::NotReadableError;
return 0;
}
if (!bytesRead) {
@@ -429,7 +418,7 @@
ASSERT(m_async);
// Do not continue if the request is aborted or an error occurs.
- if (m_aborted || m_errorCode)
+ if (erroredOrAborted())
return;
// If there is no more remaining data to read, we are done.
@@ -485,7 +474,7 @@
ASSERT(m_async);
if (!success) {
- failed(notReadableError);
+ failed(Error::NotReadableError);
return;
}
@@ -496,7 +485,7 @@
void BlobResourceHandle::didRead(int bytesRead)
{
if (bytesRead < 0) {
- failed(notReadableError);
+ failed(Error::NotReadableError);
return;
}
@@ -533,7 +522,7 @@
readAsync();
}
-void BlobResourceHandle::failed(int errorCode)
+void BlobResourceHandle::failed(Error errorCode)
{
ASSERT(m_async);
Ref<BlobResourceHandle> protectedThis(*this);
@@ -553,7 +542,7 @@
if (!client())
return;
- if (m_errorCode) {
+ if (m_errorCode != Error::NoError) {
Ref<BlobResourceHandle> protectedThis(*this);
notifyResponseOnError();
notifyFinish();
@@ -590,19 +579,15 @@
void BlobResourceHandle::notifyResponseOnError()
{
- ASSERT(m_errorCode);
+ ASSERT(m_errorCode != Error::NoError);
ResourceResponse response(firstRequest().url(), "text/plain", 0, String());
switch (m_errorCode) {
- case rangeError:
+ case Error::RangeError:
response.setHTTPStatusCode(httpRequestedRangeNotSatisfiable);
response.setHTTPStatusText(httpRequestedRangeNotSatisfiableText);
break;
- case notFoundError:
- response.setHTTPStatusCode(httpNotFound);
- response.setHTTPStatusText(httpNotFoundText);
- break;
- case securityError:
+ case Error::SecurityError:
response.setHTTPStatusCode(httpNotAllowed);
response.setHTTPStatusText(httpNotAllowedText);
break;
@@ -626,10 +611,10 @@
client()->didReceiveBuffer(this, SharedBuffer::create(data, bytesRead), bytesRead);
}
-void BlobResourceHandle::notifyFail(int errorCode)
+void BlobResourceHandle::notifyFail(Error errorCode)
{
if (client())
- client()->didFail(this, ResourceError(webKitBlobResourceDomain, errorCode, firstRequest().url(), String()));
+ client()->didFail(this, ResourceError(webKitBlobResourceDomain, static_cast<int>(errorCode), firstRequest().url(), String()));
}
static void doNotifyFinish(BlobResourceHandle& handle)
Modified: branches/safari-602-branch/Source/WebCore/platform/network/BlobResourceHandle.h (207204 => 207205)
--- branches/safari-602-branch/Source/WebCore/platform/network/BlobResourceHandle.h 2016-10-12 08:41:25 UTC (rev 207204)
+++ branches/safari-602-branch/Source/WebCore/platform/network/BlobResourceHandle.h 2016-10-12 08:41:31 UTC (rev 207205)
@@ -55,6 +55,15 @@
bool aborted() const { return m_aborted; }
+ enum class Error {
+ NoError = 0,
+ NotFoundError = 1,
+ SecurityError = 2,
+ RangeError = 3,
+ NotReadableError = 4,
+ MethodNotAllowed = 5
+ };
+
private:
BlobResourceHandle(BlobData*, const ResourceRequest&, ResourceHandleClient*, bool async);
virtual ~BlobResourceHandle();
@@ -72,7 +81,7 @@
void getSizeForNext();
void seek();
void consumeData(const char* data, int bytesRead);
- void failed(int errorCode);
+ void failed(Error);
void readAsync();
void readDataAsync(const BlobDataItem&);
@@ -85,9 +94,11 @@
void notifyResponseOnSuccess();
void notifyResponseOnError();
void notifyReceiveData(const char*, int);
- void notifyFail(int errorCode);
+ void notifyFail(Error);
void notifyFinish();
+ bool erroredOrAborted() const { return m_aborted || m_errorCode != Error::NoError; }
+
enum { kPositionNotSpecified = -1 };
RefPtr<BlobData> m_blobData;
@@ -96,7 +107,7 @@
std::unique_ptr<FileStream> m_stream; // For synchronous loading.
Vector<char> m_buffer;
Vector<long long> m_itemLengthList;
- int m_errorCode { 0 };
+ Error m_errorCode { Error::NoError };
bool m_aborted { false };
long long m_rangeOffset { kPositionNotSpecified };
long long m_rangeEnd { kPositionNotSpecified };