Index: LayoutTests/http/tests/xmlhttprequest/response-stream-partial-chunk.html |
diff --git a/LayoutTests/http/tests/xmlhttprequest/response-stream-partial-chunk.html b/LayoutTests/http/tests/xmlhttprequest/response-stream-partial-chunk.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..29d50b1ba57e5cdd7a0b61db1d57044161f488f1 |
--- /dev/null |
+++ b/LayoutTests/http/tests/xmlhttprequest/response-stream-partial-chunk.html |
@@ -0,0 +1,81 @@ |
+<html> |
+<body> |
+ <script src="/js-test-resources/js-test-pre.js"></script> |
+ <script type="text/javascript"> |
+description("Test partial data is readable from Stream returned by " + |
+ "XMLHttpRequest."); |
+ |
+window.jsTestIsAsync = true; |
+ |
+var xhr = new XMLHttpRequest(); |
+var reader = null; |
+ |
+function startReadingStream(stream) { |
+ reader = new FileReader(); |
+ reader.onloadstart = function() { |
+ testPassed("onloadstart invoked on reader"); |
+ }; |
+ reader.onabort = function() { |
+ testFailed("onabort invoked on reader"); |
+ finishJSTest(); |
+ }; |
+ reader.onerror = function() { |
+ testFailed("onerror invoked on reader"); |
+ finishJSTest(); |
+ }; |
+ reader.onprogress = function() { |
+ // Wait until we receive all data flushed by the server. |
+ shouldBeNonNull("reader.result"); |
+ if (reader.result == null) { |
+ finishJSTest(); |
+ return; |
+ } |
+ if (reader.result.byteLength != 5) { |
+ return; |
+ } |
+ |
+ shouldBe("reader.readyState", "reader.LOADING"); |
+ if (reader.readyState != this.LOADING) { |
+ finishJSTest(); |
+ return; |
+ } |
+ |
+ shouldBeNull("reader.error"); |
+ |
+ for (var i = 0; i < 5; ++i) { |
+ window.result = new Uint8Array(reader.result); |
+ shouldBe("result[" + i + "]", |
+ "'Hello'.charCodeAt(" + i + ")"); |
+ } |
+ |
+ finishJSTest(); |
+ } |
+ reader.onload = function() { |
+ testFailed("onload invoked on reader"); |
+ finishJSTest(); |
+ }; |
+ reader.onloadend = function() { |
+ testFailed("onloadend invoked on reader"); |
+ finishJSTest(); |
+ }; |
+ reader.readAsArrayBuffer(stream); |
+} |
+ |
+xhr.responseType = 'stream'; |
+xhr.open('GET', 'resources/chunked-transfer-hang-after-partial-data.php', true); |
+xhr.onreadystatechange = function() { |
+ if (this.readyState == this.HEADERS_RECEIVED) { |
+ shouldBeNull("xhr.response"); |
+ } else if (this.readyState == this.LOADING && reader == null) { |
+ shouldBe("xhr.status", "200"); |
+ if (this.status != 200) { |
+ finishJSTest(); |
+ return; |
+ } |
+ startReadingStream(xhr.response); |
+ } |
+}; |
+xhr.send(); |
+ </script> |
+ <script src="/js-test-resources/js-test-post.js"></script> |
+</body> |