| Index: LayoutTests/fast/xmlhttprequest/xmlhttprequest-data-url.html
|
| diff --git a/LayoutTests/fast/xmlhttprequest/xmlhttprequest-data-url.html b/LayoutTests/fast/xmlhttprequest/xmlhttprequest-data-url.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..aadaf0930cdabf9834e3540e08d82bb8d0db4f02
|
| --- /dev/null
|
| +++ b/LayoutTests/fast/xmlhttprequest/xmlhttprequest-data-url.html
|
| @@ -0,0 +1,84 @@
|
| +<html>
|
| +<body>
|
| +<script src="../../resources/testharness.js"></script>
|
| +<script src="../../resources/testharnessreport.js"></script>
|
| +<script>
|
| +
|
| +var test = async_test("Test parsing a data URL. US-ASCII into DOMString");
|
| +test.step(function() {
|
| + var xhr = new XMLHttpRequest;
|
| + xhr.responseType = 'text';
|
| + xhr.open('GET', 'data:text/html,Foobar', true);
|
| + xhr.onreadystatechange = test.step_func(function() {
|
| + if (xhr.readyState != xhr.DONE)
|
| + return;
|
| +
|
| + assert_equals(xhr.status, 200, 'status');
|
| + assert_equals(xhr.statusText, 'OK', 'statusText');
|
| + assert_equals(xhr.getAllResponseHeaders(), 'Content-Type: text/html;charset=US-ASCII\r\n', 'getAllResponseheaders()');
|
| + assert_equals(xhr.response, 'Foobar', 'response');
|
| +
|
| + test.done();
|
| + });
|
| + xhr.send();
|
| +});
|
| +
|
| +var testArrayBuffer = async_test("Test parsing a data URL. Binary into ArrayBuffer");
|
| +testArrayBuffer.step(function() {
|
| + var xhr = new XMLHttpRequest;
|
| + xhr.responseType = 'arraybuffer';
|
| + xhr.open('GET', 'data:text/html;base64,AAEC/w%3D%3D', true);
|
| + xhr.onreadystatechange = testArrayBuffer.step_func(function() {
|
| + if (xhr.readyState != xhr.DONE)
|
| + return;
|
| +
|
| + assert_equals(xhr.status, 200, 'status');
|
| + assert_equals(xhr.response.byteLength, 4, 'byteLength');
|
| + var view = new Uint8Array(xhr.response);
|
| + assert_equals(view[0], 0x00, 'view[0]')
|
| + assert_equals(view[1], 0x01, 'view[1]')
|
| + assert_equals(view[2], 0x02, 'view[2]')
|
| + assert_equals(view[3], 0xff, 'view[3]')
|
| +
|
| + testArrayBuffer.done();
|
| + });
|
| + xhr.send();
|
| +});
|
| +
|
| +var testUtf8 = async_test("Test parsing a data URL. UTF-8 data into DOMString.");
|
| +testUtf8.step(function() {
|
| + var xhr = new XMLHttpRequest;
|
| + xhr.responseType = 'text';
|
| + xhr.open('GET', 'data:text/html;charset=utf-8;base64,5paH5a2X', true);
|
| + xhr.onreadystatechange = testUtf8.step_func(function() {
|
| + if (xhr.readyState != xhr.DONE)
|
| + return;
|
| +
|
| + assert_equals(xhr.status, 200, 'status');
|
| + assert_equals(xhr.getAllResponseHeaders(), 'Content-Type: text/html;charset=utf-8\r\n', 'getAllResponseheaders()');
|
| + assert_equals(xhr.response, '\u6587\u5b57', 'response');
|
| +
|
| + testUtf8.done();
|
| + });
|
| + xhr.send();
|
| +});
|
| +
|
| +var testBad = async_test("Test parsing a data URL. Invalid Base64 data.");
|
| +testBad.step(function() {
|
| + var xhr = new XMLHttpRequest;
|
| + xhr.responseType = 'text';
|
| + xhr.open('GET', 'data:text/html;base64,***', true);
|
| + xhr.onreadystatechange = testBad.step_func(function() {
|
| + if (xhr.readyState != xhr.DONE)
|
| + return;
|
| +
|
| + assert_not_equals(xhr.status, 200, 'status');
|
| +
|
| + testBad.done();
|
| + });
|
| + xhr.send();
|
| +});
|
| +
|
| +</script>
|
| +</body>
|
| +</html>
|
|
|