Title: [158333] trunk
- Revision
- 158333
- Author
- a...@apple.com
- Date
- 2013-10-30 17:32:58 -0700 (Wed, 30 Oct 2013)
Log Message
XHR.response is null when requesting empty file as arraybuffer
https://bugs.webkit.org/show_bug.cgi?id=123457
Source/WebCore:
Reviewed by Sam Weinig.
Test: http/tests/xmlhttprequest/response-empty-arraybuffer.html
* xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::responseArrayBuffer): Don't do this.
LayoutTests:
Based on a Blink test by yusukesuz...@chromium.org.
Reviewed by Sam Weinig.
Failures in expected results appear to mean that Blink caches XHR responses in more
cases. It's not directly related to the patch.
* http/tests/xmlhttprequest/response-empty-arraybuffer-expected.txt: Added.
* http/tests/xmlhttprequest/response-empty-arraybuffer.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (158332 => 158333)
--- trunk/LayoutTests/ChangeLog 2013-10-31 00:31:43 UTC (rev 158332)
+++ trunk/LayoutTests/ChangeLog 2013-10-31 00:32:58 UTC (rev 158333)
@@ -1,3 +1,18 @@
+2013-10-30 Alexey Proskuryakov <a...@apple.com>
+
+ XHR.response is null when requesting empty file as arraybuffer
+ https://bugs.webkit.org/show_bug.cgi?id=123457
+
+ Based on a Blink test by yusukesuz...@chromium.org.
+
+ Reviewed by Sam Weinig.
+
+ Failures in expected results appear to mean that Blink caches XHR responses in more
+ cases. It's not directly related to the patch.
+
+ * http/tests/xmlhttprequest/response-empty-arraybuffer-expected.txt: Added.
+ * http/tests/xmlhttprequest/response-empty-arraybuffer.html: Added.
+
2013-10-30 Samuel White <samuel_wh...@apple.com>
AX: AXFocused not exposed on ARIA menuitems
Added: trunk/LayoutTests/http/tests/xmlhttprequest/response-empty-arraybuffer-expected.txt (0 => 158333)
--- trunk/LayoutTests/http/tests/xmlhttprequest/response-empty-arraybuffer-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/response-empty-arraybuffer-expected.txt 2013-10-31 00:32:58 UTC (rev 158333)
@@ -0,0 +1,20 @@
+Test that XMLHttpRequest.response returns an empty ArrayBuffer when received a response without an entity body.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test that XMLHttpRequest.response returns an empty ArrayBuffer when received a response with zero content length.
+PASS request.status is 200
+PASS Object.prototype.toString.call(request.response) is '[object ArrayBuffer]'
+PASS request.response.byteLength is 0
+Test that XMLHttpRequest.response returns an empty ArrayBuffer when received status is '304 not modified'.
+PASS request.status is 200
+PASS Object.prototype.toString.call(request.response) is '[object ArrayBuffer]'
+PASS request.response.byteLength is 68
+FAIL request2.status should be 304. Was 200.
+PASS Object.prototype.toString.call(request2.response) is '[object ArrayBuffer]'
+FAIL request2.response.byteLength should be 0. Was 68.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/xmlhttprequest/response-empty-arraybuffer.html (0 => 158333)
--- trunk/LayoutTests/http/tests/xmlhttprequest/response-empty-arraybuffer.html (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/response-empty-arraybuffer.html 2013-10-31 00:32:58 UTC (rev 158333)
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body _onload_="zeroContentLengthTest()">
+<script>
+description("Test that XMLHttpRequest.response returns an empty ArrayBuffer when received a response without an entity body.");
+
+jsTestIsAsync = true;
+
+function zeroContentLengthTest()
+{
+ debug("Test that XMLHttpRequest.response returns an empty ArrayBuffer when received a response with zero content length.");
+ var req = new XMLHttpRequest;
+ req.responseType = 'arraybuffer';
+ req.open('GET', 'resources/zero-length.xml', true);
+ req._onreadystatechange_ = function() {
+ if (req.readyState != 4)
+ return;
+
+ request = req;
+
+ shouldBe("request.status", "200");
+ shouldBe("Object.prototype.toString.call(request.response)", "'[object ArrayBuffer]'");
+ shouldBe("request.response.byteLength", "0");
+ notModifiedTest();
+ }
+ req.send(null);
+}
+
+
+function notModifiedTest()
+{
+ debug("Test that XMLHttpRequest.response returns an empty ArrayBuffer when received status is '304 not modified'.");
+
+ var req = new XMLHttpRequest;
+ req.responseType = 'arraybuffer';
+ req.open('GET', 'resources/reply.xml', true);
+ req._onreadystatechange_ = function() {
+ if (req.readyState != 4)
+ return;
+
+ request = req;
+
+ shouldBe("request.status", "200");
+ shouldBe("Object.prototype.toString.call(request.response)", "'[object ArrayBuffer]'");
+ shouldBe("request.response.byteLength", "68");
+
+ var lastModified = req.getResponseHeader("Last-Modified");
+
+ var req2 = new XMLHttpRequest;
+ req2.responseType = 'arraybuffer';
+ req2.open('GET', 'resources/reply.xml', true);
+ req2.setRequestHeader("If-Modified-Since", lastModified);
+ req2._onreadystatechange_ = function() {
+ if (req2.readyState != 4)
+ return;
+
+ request2 = req;
+
+ shouldBe("request2.status", "304");
+ shouldBe("Object.prototype.toString.call(request2.response)", "'[object ArrayBuffer]'");
+ shouldBe("request2.response.byteLength", "0");
+
+ finishJSTest();
+ }
+ req2.send(null);
+ }
+ req.send(null);
+}
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (158332 => 158333)
--- trunk/Source/WebCore/ChangeLog 2013-10-31 00:31:43 UTC (rev 158332)
+++ trunk/Source/WebCore/ChangeLog 2013-10-31 00:32:58 UTC (rev 158333)
@@ -1,3 +1,14 @@
+2013-10-30 Alexey Proskuryakov <a...@apple.com>
+
+ XHR.response is null when requesting empty file as arraybuffer
+ https://bugs.webkit.org/show_bug.cgi?id=123457
+
+ Reviewed by Sam Weinig.
+
+ Test: http/tests/xmlhttprequest/response-empty-arraybuffer.html
+
+ * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::responseArrayBuffer): Don't do this.
+
2013-10-30 Samuel White <samuel_wh...@apple.com>
AX: AXFocused not exposed on ARIA menuitems
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (158332 => 158333)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2013-10-31 00:31:43 UTC (rev 158332)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2013-10-31 00:32:58 UTC (rev 158333)
@@ -325,8 +325,11 @@
if (m_state != DONE)
return 0;
- if (!m_responseArrayBuffer.get() && m_binaryResponseBuilder.get() && m_binaryResponseBuilder->size() > 0) {
- m_responseArrayBuffer = ArrayBuffer::create(const_cast<char*>(m_binaryResponseBuilder->data()), static_cast<unsigned>(m_binaryResponseBuilder->size()));
+ if (!m_responseArrayBuffer) {
+ if (m_binaryResponseBuilder)
+ m_responseArrayBuffer = ArrayBuffer::create(const_cast<char*>(m_binaryResponseBuilder->data()), static_cast<unsigned>(m_binaryResponseBuilder->size()));
+ else
+ m_responseArrayBuffer = ArrayBuffer::create(nullptr, 0);
m_binaryResponseBuilder.clear();
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes