| 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"); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 72 xhr.responseType = 'blob'; | 72 xhr.responseType = 'blob'; |
| 73 xhr.open('GET', 'data:text/html;charset=utf-8;base64,5paH5a2X', true); | 73 xhr.open('GET', 'data:text/html;charset=utf-8;base64,5paH5a2X', true); |
| 74 xhr.onreadystatechange = testUtf8Blob.step_func(function() { | 74 xhr.onreadystatechange = testUtf8Blob.step_func(function() { |
| 75 if (xhr.readyState != xhr.DONE) | 75 if (xhr.readyState != xhr.DONE) |
| 76 return; | 76 return; |
| 77 | 77 |
| 78 assert_equals(xhr.status, 200, 'status'); | 78 assert_equals(xhr.status, 0, 'status'); |
| 79 assert_not_equals(xhr.response, null, 'response'); | 79 assert_equals(xhr.response, null, 'response'); |
| 80 assert_equals(xhr.response.type, 'text/html', 'response.type'); | 80 testUtf8Blob.done(); |
| 81 var reader = new FileReader(); | |
| 82 reader.onabort = testUtf8Blob.step_func(function() { assert_unreached('o
nabort'); }); | |
| 83 reader.onerror = testUtf8Blob.step_func(function() { assert_unreached('o
nerror'); }); | |
| 84 reader.onload = testUtf8Blob.step_func(function() { | |
| 85 assert_equals(reader.result, '\u6587\u5b57', 'result'); | |
| 86 testUtf8Blob.done(); | |
| 87 }); | |
| 88 reader.readAsText(xhr.response); | |
| 89 }); | 81 }); |
| 90 xhr.send(); | 82 xhr.send(); |
| 91 }); | 83 }); |
| 92 | 84 |
| 93 var testBad = async_test("Test parsing a data URL. Invalid Base64 data."); | 85 var testBad = async_test("Test parsing a data URL. Invalid Base64 data."); |
| 94 testBad.step(function() { | 86 testBad.step(function() { |
| 95 var xhr = new XMLHttpRequest; | 87 var xhr = new XMLHttpRequest; |
| 96 xhr.responseType = 'text'; | 88 xhr.responseType = 'text'; |
| 97 xhr.open('GET', 'data:text/html;base64,***', true); | 89 xhr.open('GET', 'data:text/html;base64,***', true); |
| 98 xhr.onreadystatechange = testBad.step_func(function() { | 90 xhr.onreadystatechange = testBad.step_func(function() { |
| 99 if (xhr.readyState != xhr.DONE) | 91 if (xhr.readyState != xhr.DONE) |
| 100 return; | 92 return; |
| 101 | 93 |
| 102 assert_not_equals(xhr.status, 200, 'status'); | 94 assert_not_equals(xhr.status, 200, 'status'); |
| 103 | 95 |
| 104 testBad.done(); | 96 testBad.done(); |
| 105 }); | 97 }); |
| 106 xhr.send(); | 98 xhr.send(); |
| 107 }); | 99 }); |
| 108 | 100 |
| 109 </script> | 101 </script> |
| 110 </body> | 102 </body> |
| 111 </html> | 103 </html> |
| OLD | NEW |