Changeset 207258 in webkit


Ignore:
Timestamp:
Oct 12, 2016 4:02:14 PM (8 years ago)
Author:
matthew_hanson@apple.com
Message:

Merge r205190. rdar://problem/28545010

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  
     12016-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
    1152016-10-12  Matthew Hanson  <matthew_hanson@apple.com>
    216
  • branches/safari-602.2.14.0-branch/LayoutTests/fast/files/apply-blob-url-to-xhr-expected.txt

    r195588 r207258  
    66Received exception 19: NetworkError
    77Test that XMLHttpRequest GET fails after the blob URL is revoked.
    8 Status: 404
    9 Response:
     8Received exception 19: NetworkError
    109DONE
    1110
  • branches/safari-602.2.14.0-branch/LayoutTests/fast/files/workers/worker-apply-blob-url-to-xhr-expected.txt

    r195588 r207258  
    66Received exception 19: NetworkError
    77Test that XMLHttpRequest GET fails after the blob URL is revoked.
    8 Status: 404
    9 Response:
     8Received exception 19: NetworkError
    109DONE
    1110
  • branches/safari-602.2.14.0-branch/LayoutTests/imported/w3c/ChangeLog

    r203347 r207258  
     12016-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
    1192016-07-18  Youenn Fablet  <youenn@apple.com>
    220
  • branches/safari-602.2.14.0-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob-expected.txt

    r201557 r207258  
    11
    22PASS Fetching [GET] URL.createObjectURL(blob) is OK
    3 PASS Fetching [GET] blob:http://www.localhost:8800/ is KO
     3PASS Fetching [GET] not found blob URL is KO
    44PASS Fetching [POST] URL.createObjectURL(blob) is KO
    55PASS 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  
    11
    22PASS Fetching [GET] URL.createObjectURL(blob) is OK
    3 PASS Fetching [GET] blob:http://www.localhost:8800/ is KO
     3PASS Fetching [GET] not found blob URL is KO
    44PASS Fetching [POST] URL.createObjectURL(blob) is KO
    55PASS 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  
    1212  <body>
    1313    <script>
    14       fetch_tests_from_worker(new Worker("scheme-blob.js?pipe=sub"));
     14      fetch_tests_from_worker(new Worker("scheme-blob.js"));
    1515    </script>
    1616  </body>
  • branches/safari-602.2.14.0-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.html

    r197748 r207258  
    1212  <body>
    1313    <script src="../resources/utils.js"></script>
    14     <script src="scheme-blob.js?pipe=sub"></script>
     14    <script src="scheme-blob.js"></script>
    1515  </body>
    1616</html>
  • branches/safari-602.2.14.0-branch/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-blob.js

    r201557 r207258  
    3131
    3232var 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");
     33var blob2URL = URL.createObjectURL(blob2);
     34checkKoUrl(blob2URL + "notfoundblob", "GET",
     35          "Fetching [GET] not found blob URL is KO");
    3536
    3637var invalidRequestMethods = [
     
    4344];
    4445invalidRequestMethods.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");
    4647});
    4748
  • branches/safari-602.2.14.0-branch/Source/WebCore/ChangeLog

    r207256 r207258  
     12016-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
    1412016-10-12  Matthew Hanson  <matthew_hanson@apple.com>
    242
  • branches/safari-602.2.14.0-branch/Source/WebCore/fileapi/FileReaderLoader.cpp

    r203322 r207258  
    3737#include "FileReaderLoaderClient.h"
    3838#include "HTTPHeaderNames.h"
     39#include "ResourceError.h"
    3940#include "ResourceRequest.h"
    4041#include "ResourceResponse.h"
     
    228229}
    229230
    230 void FileReaderLoader::didFail(const ResourceError&)
     231void FileReaderLoader::didFail(const ResourceError& error)
    231232{
    232233    // If we're aborting, do not proceed with normal error handling since it is covered in aborting code.
     
    234235        return;
    235236
    236     failed(FileError::NOT_READABLE_ERR);
     237    failed(toErrorCode(static_cast<BlobResourceHandle::Error>(error.errorCode())));
    237238}
    238239
     
    243244    if (m_client)
    244245        m_client->didFail(m_errorCode);
     246}
     247
     248FileError::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    }
    245256}
    246257
     
    250261    case 403:
    251262        return FileError::SECURITY_ERR;
    252     case 404:
    253         return FileError::NOT_FOUND_ERR;
    254263    default:
    255264        return FileError::NOT_READABLE_ERR;
  • branches/safari-602.2.14.0-branch/Source/WebCore/fileapi/FileReaderLoader.h

    r199985 r207258  
    3232#define FileReaderLoader_h
    3333
     34#include "BlobResourceHandle.h"
    3435#include "FileError.h"
    3536#include "URL.h"
     
    9394
    9495    static FileError::ErrorCode httpStatusCodeToErrorCode(int);
     96    static FileError::ErrorCode toErrorCode(BlobResourceHandle::Error);
    9597
    9698    ReadType m_readType;
  • branches/safari-602.2.14.0-branch/Source/WebCore/platform/network/BlobResourceHandle.cpp

    r203303 r207258  
    5656static const int httpPartialContent = 206;
    5757static const int httpNotAllowed = 403;
    58 static const int httpNotFound = 404;
    5958static const int httpRequestedRangeNotSatisfiable = 416;
    6059static const int httpInternalError = 500;
     
    6261static const char* httpPartialContentText = "Partial Content";
    6362static const char* httpNotAllowedText = "Not Allowed";
    64 static const char* httpNotFoundText = "Not Found";
    6563static const char* httpRequestedRangeNotSatisfiableText = "Requested Range Not Satisfiable";
    6664static const char* httpInternalErrorText = "Internal Server Error";
    6765
    6866static const char* const webKitBlobResourceDomain = "WebKitBlobResource";
    69 enum {
    70     notFoundError = 1,
    71     securityError = 2,
    72     rangeError = 3,
    73     notReadableError = 4,
    74     methodNotAllowed = 5
    75 };
    7667
    7768///////////////////////////////////////////////////////////////////////////////
     
    10495    // We cannot handle the size that is more than maximum integer.
    10596    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");
    10798        return;
    10899    }
     
    133124{
    134125    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");
    136127        return;
    137128    }
     
    189180
    190181    // Do not continue if the request is aborted or an error occurs.
    191     if (m_aborted || m_errorCode)
     182    if (erroredOrAborted())
    192183        return;
    193184
    194185    if (!equalLettersIgnoringASCIICase(firstRequest().httpMethod(), "get")) {
    195         notifyFail(methodNotAllowed);
     186        notifyFail(Error::MethodNotAllowed);
    196187        return;
    197188    }
     
    199190    // If the blob data is not found, fail now.
    200191    if (!m_blobData) {
    201         m_errorCode = notFoundError;
    202         notifyResponse();
     192        notifyFail(Error::NotFoundError);
    203193        return;
    204194    }
     
    207197    String range = firstRequest().httpHeaderField(HTTPHeaderName::Range);
    208198    if (!range.isEmpty() && !parseRange(range, m_rangeOffset, m_rangeEnd, m_rangeSuffixLength)) {
    209         m_errorCode = rangeError;
     199        m_errorCode = Error::RangeError;
    210200        notifyResponse();
    211201        return;
     
    216206    else {
    217207        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)
    219209            getSizeForNext();
    220210        notifyResponse();
     
    262252
    263253    // Do not continue if the request is aborted or an error occurs.
    264     if (m_aborted || m_errorCode)
     254    if (erroredOrAborted())
    265255        return;
    266256
    267257    // If the size is -1, it means the file has been moved or changed. Fail now.
    268258    if (size == -1) {
    269         m_errorCode = notFoundError;
    270         notifyResponse();
     259        notifyFail(Error::NotFoundError);
    271260        return;
    272261    }
     
    330319    while (remaining) {
    331320        // Do not continue if the request is aborted or an error occurs.
    332         if (m_aborted || m_errorCode)
     321        if (erroredOrAborted())
    333322            break;
    334323
     
    336325        if (!m_totalRemainingSize || m_readItemCount >= m_blobData->items().size())
    337326            break;
    338        
     327
    339328        const BlobDataItem& item = m_blobData->items().at(m_readItemCount);
    340329        int bytesRead = 0;
     
    353342
    354343    int result;
    355     if (m_aborted || m_errorCode)
     344    if (erroredOrAborted())
    356345        result = -1;
    357346    else
     
    402391        m_currentItemReadSize = 0;
    403392        if (!success) {
    404             m_errorCode = notReadableError;
     393            m_errorCode = Error::NotReadableError;
    405394            return 0;
    406395        }
     
    411400    int bytesRead = m_stream->read(buf, length);
    412401    if (bytesRead < 0) {
    413         m_errorCode = notReadableError;
     402        m_errorCode = Error::NotReadableError;
    414403        return 0;
    415404    }
     
    430419
    431420    // Do not continue if the request is aborted or an error occurs.
    432     if (m_aborted || m_errorCode)
     421    if (erroredOrAborted())
    433422        return;
    434423
     
    486475
    487476    if (!success) {
    488         failed(notReadableError);
     477        failed(Error::NotReadableError);
    489478        return;
    490479    }
     
    497486{
    498487    if (bytesRead < 0) {
    499         failed(notReadableError);
     488        failed(Error::NotReadableError);
    500489        return;
    501490    }
     
    534523}
    535524
    536 void BlobResourceHandle::failed(int errorCode)
     525void BlobResourceHandle::failed(Error errorCode)
    537526{
    538527    ASSERT(m_async);
     
    554543        return;
    555544
    556     if (m_errorCode) {
     545    if (m_errorCode != Error::NoError) {
    557546        Ref<BlobResourceHandle> protectedThis(*this);
    558547        notifyResponseOnError();
     
    591580void BlobResourceHandle::notifyResponseOnError()
    592581{
    593     ASSERT(m_errorCode);
     582    ASSERT(m_errorCode != Error::NoError);
    594583
    595584    ResourceResponse response(firstRequest().url(), "text/plain", 0, String());
    596585    switch (m_errorCode) {
    597     case rangeError:
     586    case Error::RangeError:
    598587        response.setHTTPStatusCode(httpRequestedRangeNotSatisfiable);
    599588        response.setHTTPStatusText(httpRequestedRangeNotSatisfiableText);
    600589        break;
    601     case notFoundError:
    602         response.setHTTPStatusCode(httpNotFound);
    603         response.setHTTPStatusText(httpNotFoundText);
    604         break;
    605     case securityError:
     590    case Error::SecurityError:
    606591        response.setHTTPStatusCode(httpNotAllowed);
    607592        response.setHTTPStatusText(httpNotAllowedText);
     
    627612}
    628613
    629 void BlobResourceHandle::notifyFail(int errorCode)
     614void BlobResourceHandle::notifyFail(Error errorCode)
    630615{
    631616    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()));
    633618}
    634619
  • branches/safari-602.2.14.0-branch/Source/WebCore/platform/network/BlobResourceHandle.h

    r201761 r207258  
    5656    bool aborted() const { return m_aborted; }
    5757
     58    enum class Error {
     59        NoError = 0,
     60        NotFoundError = 1,
     61        SecurityError = 2,
     62        RangeError = 3,
     63        NotReadableError = 4,
     64        MethodNotAllowed = 5
     65    };
     66
    5867private:
    5968    BlobResourceHandle(BlobData*, const ResourceRequest&, ResourceHandleClient*, bool async);
     
    7382    void seek();
    7483    void consumeData(const char* data, int bytesRead);
    75     void failed(int errorCode);
     84    void failed(Error);
    7685
    7786    void readAsync();
     
    8695    void notifyResponseOnError();
    8796    void notifyReceiveData(const char*, int);
    88     void notifyFail(int errorCode);
     97    void notifyFail(Error);
    8998    void notifyFinish();
     99
     100    bool erroredOrAborted() const { return m_aborted || m_errorCode != Error::NoError; }
    90101
    91102    enum { kPositionNotSpecified = -1 };
     
    97108    Vector<char> m_buffer;
    98109    Vector<long long> m_itemLengthList;
    99     int m_errorCode { 0 };
     110    Error m_errorCode { Error::NoError };
    100111    bool m_aborted { false };
    101112    long long m_rangeOffset { kPositionNotSpecified };
Note: See TracChangeset for help on using the changeset viewer.