Changeset 109635 in webkit


Ignore:
Timestamp:
Mar 2, 2012 4:57:10 PM (12 years ago)
Author:
eric@webkit.org
Message:

Chrome 18 fails html5test.com XHR Blob response test
https://bugs.webkit.org/show_bug.cgi?id=76760

Reviewed by Adam Barth.

Source/WebCore:

Most of the code was already there, this just fixes the FIXME
which was causing this feature not to work. Chromium already
had this #ifdef enabled, but other ports (at least Mac) do not.

Test: fast/files/xhr-response-blob.html

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::didFinishLoading):

LayoutTests:

  • fast/files/script-tests/xhr-response-blob.js: Added.

(xhr.onreadystatechange):

  • fast/files/xhr-response-blob-expected.txt: Added.
  • fast/files/xhr-response-blob.html: Added.
  • platform/chromium/fast/files/xhr-response-blob-expected.txt: Added.
Location:
trunk
Files:
5 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r109632 r109635  
     12012-03-01  Eric Seidel  <eric@webkit.org>
     2
     3        Chrome 18 fails html5test.com XHR Blob response test
     4        https://bugs.webkit.org/show_bug.cgi?id=76760
     5
     6        Reviewed by Adam Barth.
     7
     8        * fast/files/script-tests/xhr-response-blob.js: Added.
     9        (xhr.onreadystatechange):
     10        * fast/files/xhr-response-blob-expected.txt: Added.
     11        * fast/files/xhr-response-blob.html: Added.
     12        * platform/chromium/fast/files/xhr-response-blob-expected.txt: Added.
     13
    1142012-03-02  Adam Klein  <adamk@chromium.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r109634 r109635  
     12012-03-01  Eric Seidel  <eric@webkit.org>
     2
     3        Chrome 18 fails html5test.com XHR Blob response test
     4        https://bugs.webkit.org/show_bug.cgi?id=76760
     5
     6        Reviewed by Adam Barth.
     7
     8        Most of the code was already there, this just fixes the FIXME
     9        which was causing this feature not to work.  Chromium already
     10        had this #ifdef enabled, but other ports (at least Mac) do not.
     11
     12        Test: fast/files/xhr-response-blob.html
     13
     14        * xml/XMLHttpRequest.cpp:
     15        (WebCore::XMLHttpRequest::didFinishLoading):
     16
    1172012-03-02  Kentaro Hara  <haraken@chromium.org>
    218
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r108506 r109635  
    2424
    2525#include "Blob.h"
     26#include "BlobData.h"
    2627#include "ContentSecurityPolicy.h"
    2728#include "CrossOriginAccessControl.h"
     
    263264
    264265#if ENABLE(XHR_RESPONSE_BLOB)
    265 Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) const
     266Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec)
    266267{
    267268    if (m_responseTypeCode != ResponseTypeBlob) {
     
    269270        return 0;
    270271    }
     272    // We always return null before DONE.
     273    if (m_state != DONE)
     274        return 0;
     275
     276    if (!m_responseBlob.get()) {
     277        // FIXME: This causes two (or more) unnecessary copies of the data.
     278        // Chromium stores blob data in the browser process, so we're pulling the data
     279        // from the network only to copy it into the renderer to copy it back to the browser.
     280        // Ideally we'd get the blob/file-handle from the ResourceResponse directly
     281        // instead of copying the bytes. Embedders who store blob data in the
     282        // same process as WebCore would at least to teach BlobData to take
     283        // a SharedBuffer, even if they don't get the Blob from the network layer directly.
     284        OwnPtr<BlobData> blobData = BlobData::create();
     285        // If we errored out or got no data, we still return a blob, just an empty one.
     286        if (m_binaryResponseBuilder.get()) {
     287            RefPtr<RawData> rawData = RawData::create();
     288            size_t size = m_binaryResponseBuilder->size();
     289            rawData->mutableData()->append(m_binaryResponseBuilder->data(), size);
     290            blobData->appendData(rawData, 0, BlobDataItem::toEndOfFile);
     291            blobData->setContentType(responseMIMEType()); // responseMIMEType defaults to text/xml which may be incorrect.
     292            m_binaryResponseBuilder.clear();
     293        }
     294        m_responseBlob = Blob::create(blobData.release(), m_binaryResponseBuilder.get() ? m_binaryResponseBuilder->size() : 0);
     295    }
     296
    271297    return m_responseBlob.get();
    272298}
     
    288314    }
    289315
    290     if (m_responseArrayBuffer.get())
    291         return m_responseArrayBuffer.get();
    292 
    293     return 0;
     316    return m_responseArrayBuffer.get();
    294317}
    295318
     
    10341057    m_responseBuilder.shrinkToFit();
    10351058
    1036 #if ENABLE(XHR_RESPONSE_BLOB)
    1037     // FIXME: Set m_responseBlob to something here in the ResponseTypeBlob case.
    1038 #endif
    1039 
    10401059    InspectorInstrumentation::resourceRetrievedByXMLHttpRequest(scriptExecutionContext(), identifier, m_responseBuilder.toStringPreserveCapacity(), m_url, m_lastSendURL, m_lastSendLineNumber);
    10411060
     
    11071126    if (useDecoder)
    11081127        m_responseBuilder.append(m_decoder->decode(data, len));
    1109     else if (m_responseTypeCode == ResponseTypeArrayBuffer) {
     1128    else if (m_responseTypeCode == ResponseTypeArrayBuffer
     1129#if ENABLE(XHR_RESPONSE_BLOB)
     1130             || m_responseTypeCode == ResponseTypeBlob
     1131#endif
     1132             ) {
    11101133        // Buffer binary data.
    11111134        if (!m_binaryResponseBuilder)
  • trunk/Source/WebCore/xml/XMLHttpRequest.h

    r103502 r109635  
    107107    Document* optionalResponseXML() const { return m_responseDocument.get(); }
    108108#if ENABLE(XHR_RESPONSE_BLOB)
    109     Blob* responseBlob(ExceptionCode&) const;
     109    Blob* responseBlob(ExceptionCode&);
    110110    Blob* optionalResponseBlob() const { return m_responseBlob.get(); }
    111111#endif
Note: See TracChangeset for help on using the changeset viewer.