Title: [120042] trunk
Revision
120042
Author
kin...@chromium.org
Date
2012-06-11 23:17:27 -0700 (Mon, 11 Jun 2012)

Log Message

XHR returns size==0 Blob
https://bugs.webkit.org/show_bug.cgi?id=88750

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Response Blob's .size field must have the correct response size.

Test: http/tests/xmlhttprequest/response-blob-size.html

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::responseBlob):

LayoutTests:

* http/tests/xmlhttprequest/response-blob-size-expected.txt: Added.
* http/tests/xmlhttprequest/response-blob-size.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (120041 => 120042)


--- trunk/LayoutTests/ChangeLog	2012-06-12 06:03:08 UTC (rev 120041)
+++ trunk/LayoutTests/ChangeLog	2012-06-12 06:17:27 UTC (rev 120042)
@@ -1,3 +1,13 @@
+2012-06-11  Kinuko Yasuda  <kin...@chromium.org>
+
+        XHR returns size==0 Blob
+        https://bugs.webkit.org/show_bug.cgi?id=88750
+
+        Reviewed by Alexey Proskuryakov.
+
+        * http/tests/xmlhttprequest/response-blob-size-expected.txt: Added.
+        * http/tests/xmlhttprequest/response-blob-size.html: Added.
+
 2012-06-11  Silvia Pfeiffer  <silvi...@chromium.org>
 
         Introduce an Enclosure Element for Chromium video controls.

Added: trunk/LayoutTests/http/tests/xmlhttprequest/response-blob-size-expected.txt (0 => 120042)


--- trunk/LayoutTests/http/tests/xmlhttprequest/response-blob-size-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/response-blob-size-expected.txt	2012-06-12 06:17:27 UTC (rev 120042)
@@ -0,0 +1,5 @@
+Test Blob.size of response blob received for XMLHttpRequest
+
+PASS: "200" == "200"
+PASS: "103746" == "103746"
+
Property changes on: trunk/LayoutTests/http/tests/xmlhttprequest/response-blob-size-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/http/tests/xmlhttprequest/response-blob-size.html (0 => 120042)


--- trunk/LayoutTests/http/tests/xmlhttprequest/response-blob-size.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/response-blob-size.html	2012-06-12 06:17:27 UTC (rev 120042)
@@ -0,0 +1,36 @@
+<html>
+<body>
+<p>Test Blob.size of response blob received for XMLHttpRequest</p>
+<pre id="console"></pre>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+function log(text)
+{
+    var console = document.getElementById('console');
+    console.appendChild(document.createTextNode(text + '\n'));
+}
+
+function test(expect, actual)
+{
+    log((expect == actual ? 'PASS' : 'FAIL') + ': "' + expect + '" == "' + actual + '"');
+}
+
+var req = new XMLHttpRequest;
+req.responseType = 'blob';
+req.open('GET', '../resources/test.ogv', true);
+req._onreadystatechange_ = function() {
+    if (req.readyState == 4) {
+        test(200, req.status);
+        test(103746, req.response.size)
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+};
+req.send(null);
+
+</script>
+</body>
Property changes on: trunk/LayoutTests/http/tests/xmlhttprequest/response-blob-size.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (120041 => 120042)


--- trunk/Source/WebCore/ChangeLog	2012-06-12 06:03:08 UTC (rev 120041)
+++ trunk/Source/WebCore/ChangeLog	2012-06-12 06:17:27 UTC (rev 120042)
@@ -1,3 +1,17 @@
+2012-06-11  Kinuko Yasuda  <kin...@chromium.org>
+
+        XHR returns size==0 Blob
+        https://bugs.webkit.org/show_bug.cgi?id=88750
+
+        Reviewed by Alexey Proskuryakov.
+
+        Response Blob's .size field must have the correct response size.
+
+        Test: http/tests/xmlhttprequest/response-blob-size.html
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::responseBlob):
+
 2012-06-11  Silvia Pfeiffer  <silvi...@chromium.org>
 
         Introduce an Enclosure Element for Chromium video controls.

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (120041 => 120042)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2012-06-12 06:03:08 UTC (rev 120041)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2012-06-12 06:17:27 UTC (rev 120042)
@@ -273,7 +273,7 @@
     if (m_state != DONE)
         return 0;
 
-    if (!m_responseBlob.get()) {
+    if (!m_responseBlob) {
         // FIXME: This causes two (or more) unnecessary copies of the data.
         // Chromium stores blob data in the browser process, so we're pulling the data
         // from the network only to copy it into the renderer to copy it back to the browser.
@@ -283,15 +283,16 @@
         // a SharedBuffer, even if they don't get the Blob from the network layer directly.
         OwnPtr<BlobData> blobData = BlobData::create();
         // If we errored out or got no data, we still return a blob, just an empty one.
-        if (m_binaryResponseBuilder.get()) {
+        size_t size = 0;
+        if (m_binaryResponseBuilder) {
             RefPtr<RawData> rawData = RawData::create();
-            size_t size = m_binaryResponseBuilder->size();
+            size = m_binaryResponseBuilder->size();
             rawData->mutableData()->append(m_binaryResponseBuilder->data(), size);
             blobData->appendData(rawData, 0, BlobDataItem::toEndOfFile);
             blobData->setContentType(responseMIMEType()); // responseMIMEType defaults to text/xml which may be incorrect.
             m_binaryResponseBuilder.clear();
         }
-        m_responseBlob = Blob::create(blobData.release(), m_binaryResponseBuilder.get() ? m_binaryResponseBuilder->size() : 0);
+        m_responseBlob = Blob::create(blobData.release(), size);
     }
 
     return m_responseBlob.get();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to