OLD | NEW |
1 <html> | 1 <html> |
2 <body> | 2 <body> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <script> | 5 <script> |
6 // This test must be run over HTTP. Otherwise, content_shell runs it with file: | 6 // This test must be run over HTTP. Otherwise, content_shell runs it with file: |
7 // scheme and then the access to data: resources are handled as same origin | 7 // scheme and then the access to data: resources are handled as same origin |
8 // access. | 8 // access. |
9 | 9 |
10 var test = async_test("Test parsing a data URL. US-ASCII into DOMString"); | 10 var test = async_test("Test parsing a data URL. US-ASCII into DOMString"); |
11 test.step(function() { | 11 test.step(function() { |
12 var xhr = new XMLHttpRequest; | 12 var xhr = new XMLHttpRequest; |
13 xhr.responseType = 'text'; | 13 xhr.responseType = 'text'; |
14 xhr.open('GET', 'data:text/html,Foobar', true); | 14 xhr.open('GET', 'data:text/html,Foobar', true); |
15 xhr.onreadystatechange = test.step_func(function() { | 15 xhr.onreadystatechange = test.step_func(function() { |
16 if (xhr.readyState != xhr.DONE) | 16 if (xhr.readyState != xhr.DONE) |
17 return; | 17 return; |
18 | 18 |
19 assert_equals(xhr.status, 200, 'status'); | 19 assert_equals(xhr.status, 200, 'status'); |
20 assert_equals(xhr.statusText, 'OK', 'statusText'); | 20 assert_equals(xhr.statusText, 'OK', 'statusText'); |
21 assert_equals(xhr.getAllResponseHeaders(), 'Content-Type: text/html\r\n'
, 'getAllResponseheaders()'); | 21 assert_equals(xhr.getAllResponseHeaders(), 'content-type: text/html\r\n'
, 'getAllResponseheaders()'); |
22 assert_equals(xhr.response, 'Foobar', 'response'); | 22 assert_equals(xhr.response, 'Foobar', 'response'); |
23 | 23 |
24 test.done(); | 24 test.done(); |
25 }); | 25 }); |
26 xhr.send(); | 26 xhr.send(); |
27 }); | 27 }); |
28 | 28 |
29 var testArrayBuffer = async_test("Test parsing a data URL. Binary into ArrayBuff
er"); | 29 var testArrayBuffer = async_test("Test parsing a data URL. Binary into ArrayBuff
er"); |
30 testArrayBuffer.step(function() { | 30 testArrayBuffer.step(function() { |
31 var xhr = new XMLHttpRequest; | 31 var xhr = new XMLHttpRequest; |
(...skipping 19 matching lines...) Expand all Loading... |
51 var testUtf8 = async_test("Test parsing a data URL. UTF-8 data into DOMString.")
; | 51 var testUtf8 = async_test("Test parsing a data URL. UTF-8 data into DOMString.")
; |
52 testUtf8.step(function() { | 52 testUtf8.step(function() { |
53 var xhr = new XMLHttpRequest; | 53 var xhr = new XMLHttpRequest; |
54 xhr.responseType = 'text'; | 54 xhr.responseType = 'text'; |
55 xhr.open('GET', 'data:text/html;charset=utf-8;base64,5paH5a2X', true); | 55 xhr.open('GET', 'data:text/html;charset=utf-8;base64,5paH5a2X', true); |
56 xhr.onreadystatechange = testUtf8.step_func(function() { | 56 xhr.onreadystatechange = testUtf8.step_func(function() { |
57 if (xhr.readyState != xhr.DONE) | 57 if (xhr.readyState != xhr.DONE) |
58 return; | 58 return; |
59 | 59 |
60 assert_equals(xhr.status, 200, 'status'); | 60 assert_equals(xhr.status, 200, 'status'); |
61 assert_equals(xhr.getAllResponseHeaders(), 'Content-Type: text/html;char
set=utf-8\r\n', 'getAllResponseheaders()'); | 61 assert_equals(xhr.getAllResponseHeaders(), 'content-type: text/html;char
set=utf-8\r\n', 'getAllResponseheaders()'); |
62 assert_equals(xhr.response, '\u6587\u5b57', 'response'); | 62 assert_equals(xhr.response, '\u6587\u5b57', 'response'); |
63 | 63 |
64 testUtf8.done(); | 64 testUtf8.done(); |
65 }); | 65 }); |
66 xhr.send(); | 66 xhr.send(); |
67 }); | 67 }); |
68 | 68 |
69 var testUtf8Blob = async_test("Test parsing a data URL. UTF-8 data into Blob."); | 69 var testUtf8Blob = async_test("Test parsing a data URL. UTF-8 data into Blob."); |
70 testUtf8Blob.step(function() { | 70 testUtf8Blob.step(function() { |
71 var xhr = new XMLHttpRequest; | 71 var xhr = new XMLHttpRequest; |
(...skipping 22 matching lines...) Expand all Loading... |
94 assert_not_equals(xhr.status, 200, 'status'); | 94 assert_not_equals(xhr.status, 200, 'status'); |
95 | 95 |
96 testBad.done(); | 96 testBad.done(); |
97 }); | 97 }); |
98 xhr.send(); | 98 xhr.send(); |
99 }); | 99 }); |
100 | 100 |
101 </script> | 101 </script> |
102 </body> | 102 </body> |
103 </html> | 103 </html> |
OLD | NEW |