Changeset 207258 in webkit
- Timestamp:
- Oct 12, 2016 4:02:14 PM (8 years ago)
- Location:
- branches/safari-602.2.14.0-branch
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-602.2.14.0-branch/LayoutTests/ChangeLog
r207253 r207258 1 2016-10-12 Matthew Hanson <matthew_hanson@apple.com> 2 3 Merge r205190. rdar://problem/28545010 4 5 2016-08-30 Youenn Fablet <youenn@apple.com> 6 7 [Fetch API] Blob not found URL should result in a network error 8 https://bugs.webkit.org/show_bug.cgi?id=161381 9 10 Reviewed by Sam Weinig. 11 12 * fast/files/apply-blob-url-to-xhr-expected.txt: 13 * fast/files/workers/worker-apply-blob-url-to-xhr-expected.txt: 14 1 15 2016-10-12 Matthew Hanson <matthew_hanson@apple.com> 2 16 -
branches/safari-602.2.14.0-branch/LayoutTests/fast/files/apply-blob-url-to-xhr-expected.txt
r195588 r207258 6 6 Received exception 19: NetworkError 7 7 Test that XMLHttpRequest GET fails after the blob URL is revoked. 8 Status: 404 9 Response: 8 Received exception 19: NetworkError 10 9 DONE 11 10 -
branches/safari-602.2.14.0-branch/LayoutTests/fast/files/workers/worker-apply-blob-url-to-xhr-expected.txt
r195588 r207258 6 6 Received exception 19: NetworkError 7 7 Test that XMLHttpRequest GET fails after the blob URL is revoked. 8 Status: 404 9 Response: 8 Received exception 19: NetworkError 10 9 DONE 11 10 -
branches/safari-602.2.14.0-branch/LayoutTests/imported/w3c/ChangeLog
r203347 r207258 1 2016-10-12 Matthew Hanson <matthew_hanson@apple.com> 2 3 Merge r205190. rdar://problem/28545010 4 5 2016-08-30 Youenn Fablet <youenn@apple.com> 6 7 [Fetch API] Blob not found URL should result in a network error 8 https://bugs.webkit.org/show_bug.cgi?id=161381 9 10 Reviewed by Sam Weinig. 11 12 * web-platform-tests/fetch/api/basic/scheme-blob-expected.txt: 13 * web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt: 14 * web-platform-tests/fetch/api/basic/scheme-blob-worker.html: 15 * web-platform-tests/fetch/api/basic/scheme-blob.html: 16 * web-platform-tests/fetch/api/basic/scheme-blob.js: 17 (invalidRequestMethods.forEach): 18 1 19 2016-07-18 Youenn Fablet <youenn@apple.com> 2 20 -
branches/safari-602.2.14.0-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt
r201557 r207258 1 1 2 2 PASS Fetching [GET] URL.createObjectURL(blob) is OK 3 PASS Fetching [GET] blob:http://www.localhost:8800/is KO3 PASS Fetching [GET] not found blob URL is KO 4 4 PASS Fetching [POST] URL.createObjectURL(blob) is KO 5 5 PASS Fetching [OPTIONS] URL.createObjectURL(blob) is KO -
branches/safari-602.2.14.0-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker-expected.txt
r201557 r207258 1 1 2 2 PASS Fetching [GET] URL.createObjectURL(blob) is OK 3 PASS Fetching [GET] blob:http://www.localhost:8800/is KO3 PASS Fetching [GET] not found blob URL is KO 4 4 PASS Fetching [POST] URL.createObjectURL(blob) is KO 5 5 PASS Fetching [OPTIONS] URL.createObjectURL(blob) is KO -
branches/safari-602.2.14.0-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-worker.html
r197748 r207258 12 12 <body> 13 13 <script> 14 fetch_tests_from_worker(new Worker("scheme-blob.js ?pipe=sub"));14 fetch_tests_from_worker(new Worker("scheme-blob.js")); 15 15 </script> 16 16 </body> -
branches/safari-602.2.14.0-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.html
r197748 r207258 12 12 <body> 13 13 <script src="../resources/utils.js"></script> 14 <script src="scheme-blob.js ?pipe=sub"></script>14 <script src="scheme-blob.js"></script> 15 15 </body> 16 16 </html> -
branches/safari-602.2.14.0-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js
r201557 r207258 31 31 32 32 var blob2 = new Blob(["Blob's data"], { "type" : "text/plain" }); 33 checkKoUrl("blob:http://{{domains[www]}}:{{ports[http][0]}}/", "GET", 34 "Fetching [GET] blob:http://{{domains[www]}}:{{ports[http][0]}}/ is KO"); 33 var blob2URL = URL.createObjectURL(blob2); 34 checkKoUrl(blob2URL + "notfoundblob", "GET", 35 "Fetching [GET] not found blob URL is KO"); 35 36 36 37 var invalidRequestMethods = [ … … 43 44 ]; 44 45 invalidRequestMethods.forEach(function(method) { 45 checkKoUrl( URL.createObjectURL(blob2), method, "Fetching [" + method + "] URL.createObjectURL(blob) is KO");46 checkKoUrl(blob2URL, method, "Fetching [" + method + "] URL.createObjectURL(blob) is KO"); 46 47 }); 47 48 -
branches/safari-602.2.14.0-branch/Source/WebCore/ChangeLog
r207256 r207258 1 2016-10-12 Matthew Hanson <matthew_hanson@apple.com> 2 3 Merge r205190. rdar://problem/28545010 4 5 2016-08-30 Youenn Fablet <youenn@apple.com> 6 7 [Fetch API] Blob not found URL should result in a network error 8 https://bugs.webkit.org/show_bug.cgi?id=161381 9 10 Reviewed by Sam Weinig. 11 12 Covered by rebased and updated tests. 13 14 Raising a network error if no blob can be found from the URL. 15 It is no longer notified by a 404 response. 16 17 Updated FileReaderLoader to generate the correct exception. 18 19 Made some clean-up in the code, in particular adding an enum class for BlobResourceHandle errors. 20 21 * fileapi/FileReaderLoader.cpp: 22 (WebCore::FileReaderLoader::didFail): 23 (WebCore::FileReaderLoader::toErrorCode): 24 (WebCore::FileReaderLoader::httpStatusCodeToErrorCode): 25 * fileapi/FileReaderLoader.h: 26 * platform/network/BlobResourceHandle.cpp: 27 (WebCore::BlobResourceHandle::loadResourceSynchronously): 28 (WebCore::BlobResourceHandle::doStart): 29 (WebCore::BlobResourceHandle::didGetSize): 30 (WebCore::BlobResourceHandle::readSync): 31 (WebCore::BlobResourceHandle::readFileSync): 32 (WebCore::BlobResourceHandle::readAsync): 33 (WebCore::BlobResourceHandle::didOpen): 34 (WebCore::BlobResourceHandle::didRead): 35 (WebCore::BlobResourceHandle::failed): 36 (WebCore::BlobResourceHandle::notifyResponse): 37 (WebCore::BlobResourceHandle::notifyResponseOnError): 38 (WebCore::BlobResourceHandle::notifyFail): 39 * platform/network/BlobResourceHandle.h: 40 1 41 2016-10-12 Matthew Hanson <matthew_hanson@apple.com> 2 42 -
branches/safari-602.2.14.0-branch/Source/WebCore/fileapi/FileReaderLoader.cpp
r203322 r207258 37 37 #include "FileReaderLoaderClient.h" 38 38 #include "HTTPHeaderNames.h" 39 #include "ResourceError.h" 39 40 #include "ResourceRequest.h" 40 41 #include "ResourceResponse.h" … … 228 229 } 229 230 230 void FileReaderLoader::didFail(const ResourceError& )231 void FileReaderLoader::didFail(const ResourceError& error) 231 232 { 232 233 // If we're aborting, do not proceed with normal error handling since it is covered in aborting code. … … 234 235 return; 235 236 236 failed( FileError::NOT_READABLE_ERR);237 failed(toErrorCode(static_cast<BlobResourceHandle::Error>(error.errorCode()))); 237 238 } 238 239 … … 243 244 if (m_client) 244 245 m_client->didFail(m_errorCode); 246 } 247 248 FileError::ErrorCode FileReaderLoader::toErrorCode(BlobResourceHandle::Error error) 249 { 250 switch (error) { 251 case BlobResourceHandle::Error::NotFoundError: 252 return FileError::NOT_FOUND_ERR; 253 default: 254 return FileError::NOT_READABLE_ERR; 255 } 245 256 } 246 257 … … 250 261 case 403: 251 262 return FileError::SECURITY_ERR; 252 case 404:253 return FileError::NOT_FOUND_ERR;254 263 default: 255 264 return FileError::NOT_READABLE_ERR; -
branches/safari-602.2.14.0-branch/Source/WebCore/fileapi/FileReaderLoader.h
r199985 r207258 32 32 #define FileReaderLoader_h 33 33 34 #include "BlobResourceHandle.h" 34 35 #include "FileError.h" 35 36 #include "URL.h" … … 93 94 94 95 static FileError::ErrorCode httpStatusCodeToErrorCode(int); 96 static FileError::ErrorCode toErrorCode(BlobResourceHandle::Error); 95 97 96 98 ReadType m_readType; -
branches/safari-602.2.14.0-branch/Source/WebCore/platform/network/BlobResourceHandle.cpp
r203303 r207258 56 56 static const int httpPartialContent = 206; 57 57 static const int httpNotAllowed = 403; 58 static const int httpNotFound = 404;59 58 static const int httpRequestedRangeNotSatisfiable = 416; 60 59 static const int httpInternalError = 500; … … 62 61 static const char* httpPartialContentText = "Partial Content"; 63 62 static const char* httpNotAllowedText = "Not Allowed"; 64 static const char* httpNotFoundText = "Not Found";65 63 static const char* httpRequestedRangeNotSatisfiableText = "Requested Range Not Satisfiable"; 66 64 static const char* httpInternalErrorText = "Internal Server Error"; 67 65 68 66 static const char* const webKitBlobResourceDomain = "WebKitBlobResource"; 69 enum {70 notFoundError = 1,71 securityError = 2,72 rangeError = 3,73 notReadableError = 4,74 methodNotAllowed = 575 };76 67 77 68 /////////////////////////////////////////////////////////////////////////////// … … 104 95 // We cannot handle the size that is more than maximum integer. 105 96 if (response.expectedContentLength() > INT_MAX) { 106 m_error = ResourceError(webKitBlobResourceDomain, notReadableError, response.url(), "File is too large");97 m_error = ResourceError(webKitBlobResourceDomain, static_cast<int>(BlobResourceHandle::Error::NotReadableError), response.url(), "File is too large"); 107 98 return; 108 99 } … … 133 124 { 134 125 if (!equalLettersIgnoringASCIICase(request.httpMethod(), "get")) { 135 error = ResourceError(webKitBlobResourceDomain, methodNotAllowed, response.url(), "Request method must be GET");126 error = ResourceError(webKitBlobResourceDomain, static_cast<int>(Error::MethodNotAllowed), response.url(), "Request method must be GET"); 136 127 return; 137 128 } … … 189 180 190 181 // Do not continue if the request is aborted or an error occurs. 191 if ( m_aborted || m_errorCode)182 if (erroredOrAborted()) 192 183 return; 193 184 194 185 if (!equalLettersIgnoringASCIICase(firstRequest().httpMethod(), "get")) { 195 notifyFail( methodNotAllowed);186 notifyFail(Error::MethodNotAllowed); 196 187 return; 197 188 } … … 199 190 // If the blob data is not found, fail now. 200 191 if (!m_blobData) { 201 m_errorCode = notFoundError; 202 notifyResponse(); 192 notifyFail(Error::NotFoundError); 203 193 return; 204 194 } … … 207 197 String range = firstRequest().httpHeaderField(HTTPHeaderName::Range); 208 198 if (!range.isEmpty() && !parseRange(range, m_rangeOffset, m_rangeEnd, m_rangeSuffixLength)) { 209 m_errorCode = rangeError;199 m_errorCode = Error::RangeError; 210 200 notifyResponse(); 211 201 return; … … 216 206 else { 217 207 Ref<BlobResourceHandle> protectedThis(*this); // getSizeForNext calls the client 218 for (size_t i = 0; i < m_blobData->items().size() && ! m_aborted && !m_errorCode; ++i)208 for (size_t i = 0; i < m_blobData->items().size() && !erroredOrAborted(); ++i) 219 209 getSizeForNext(); 220 210 notifyResponse(); … … 262 252 263 253 // Do not continue if the request is aborted or an error occurs. 264 if ( m_aborted || m_errorCode)254 if (erroredOrAborted()) 265 255 return; 266 256 267 257 // If the size is -1, it means the file has been moved or changed. Fail now. 268 258 if (size == -1) { 269 m_errorCode = notFoundError; 270 notifyResponse(); 259 notifyFail(Error::NotFoundError); 271 260 return; 272 261 } … … 330 319 while (remaining) { 331 320 // Do not continue if the request is aborted or an error occurs. 332 if ( m_aborted || m_errorCode)321 if (erroredOrAborted()) 333 322 break; 334 323 … … 336 325 if (!m_totalRemainingSize || m_readItemCount >= m_blobData->items().size()) 337 326 break; 338 327 339 328 const BlobDataItem& item = m_blobData->items().at(m_readItemCount); 340 329 int bytesRead = 0; … … 353 342 354 343 int result; 355 if ( m_aborted || m_errorCode)344 if (erroredOrAborted()) 356 345 result = -1; 357 346 else … … 402 391 m_currentItemReadSize = 0; 403 392 if (!success) { 404 m_errorCode = notReadableError;393 m_errorCode = Error::NotReadableError; 405 394 return 0; 406 395 } … … 411 400 int bytesRead = m_stream->read(buf, length); 412 401 if (bytesRead < 0) { 413 m_errorCode = notReadableError;402 m_errorCode = Error::NotReadableError; 414 403 return 0; 415 404 } … … 430 419 431 420 // Do not continue if the request is aborted or an error occurs. 432 if ( m_aborted || m_errorCode)421 if (erroredOrAborted()) 433 422 return; 434 423 … … 486 475 487 476 if (!success) { 488 failed( notReadableError);477 failed(Error::NotReadableError); 489 478 return; 490 479 } … … 497 486 { 498 487 if (bytesRead < 0) { 499 failed( notReadableError);488 failed(Error::NotReadableError); 500 489 return; 501 490 } … … 534 523 } 535 524 536 void BlobResourceHandle::failed( interrorCode)525 void BlobResourceHandle::failed(Error errorCode) 537 526 { 538 527 ASSERT(m_async); … … 554 543 return; 555 544 556 if (m_errorCode ) {545 if (m_errorCode != Error::NoError) { 557 546 Ref<BlobResourceHandle> protectedThis(*this); 558 547 notifyResponseOnError(); … … 591 580 void BlobResourceHandle::notifyResponseOnError() 592 581 { 593 ASSERT(m_errorCode );582 ASSERT(m_errorCode != Error::NoError); 594 583 595 584 ResourceResponse response(firstRequest().url(), "text/plain", 0, String()); 596 585 switch (m_errorCode) { 597 case rangeError:586 case Error::RangeError: 598 587 response.setHTTPStatusCode(httpRequestedRangeNotSatisfiable); 599 588 response.setHTTPStatusText(httpRequestedRangeNotSatisfiableText); 600 589 break; 601 case notFoundError: 602 response.setHTTPStatusCode(httpNotFound); 603 response.setHTTPStatusText(httpNotFoundText); 604 break; 605 case securityError: 590 case Error::SecurityError: 606 591 response.setHTTPStatusCode(httpNotAllowed); 607 592 response.setHTTPStatusText(httpNotAllowedText); … … 627 612 } 628 613 629 void BlobResourceHandle::notifyFail( interrorCode)614 void BlobResourceHandle::notifyFail(Error errorCode) 630 615 { 631 616 if (client()) 632 client()->didFail(this, ResourceError(webKitBlobResourceDomain, errorCode, firstRequest().url(), String()));617 client()->didFail(this, ResourceError(webKitBlobResourceDomain, static_cast<int>(errorCode), firstRequest().url(), String())); 633 618 } 634 619 -
branches/safari-602.2.14.0-branch/Source/WebCore/platform/network/BlobResourceHandle.h
r201761 r207258 56 56 bool aborted() const { return m_aborted; } 57 57 58 enum class Error { 59 NoError = 0, 60 NotFoundError = 1, 61 SecurityError = 2, 62 RangeError = 3, 63 NotReadableError = 4, 64 MethodNotAllowed = 5 65 }; 66 58 67 private: 59 68 BlobResourceHandle(BlobData*, const ResourceRequest&, ResourceHandleClient*, bool async); … … 73 82 void seek(); 74 83 void consumeData(const char* data, int bytesRead); 75 void failed( int errorCode);84 void failed(Error); 76 85 77 86 void readAsync(); … … 86 95 void notifyResponseOnError(); 87 96 void notifyReceiveData(const char*, int); 88 void notifyFail( int errorCode);97 void notifyFail(Error); 89 98 void notifyFinish(); 99 100 bool erroredOrAborted() const { return m_aborted || m_errorCode != Error::NoError; } 90 101 91 102 enum { kPositionNotSpecified = -1 }; … … 97 108 Vector<char> m_buffer; 98 109 Vector<long long> m_itemLengthList; 99 int m_errorCode { 0};110 Error m_errorCode { Error::NoError }; 100 111 bool m_aborted { false }; 101 112 long long m_rangeOffset { kPositionNotSpecified };
Note: See TracChangeset
for help on using the changeset viewer.