OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset="utf-8"> | 2 <meta charset="utf-8"> |
3 <title>FileAPI Test: Creating Blob URL via XMLHttpRequest</title> | 3 <title>FileAPI Test: Creating Blob URL via XMLHttpRequest</title> |
4 <link rel="author" title="Intel" href="http://www.intel.com"> | 4 <link rel="author" title="Intel" href="http://www.intel.com"> |
5 <link rel="author" title="JunChen Xia" href="mailto:xjconlyme@gmail.com"> | 5 <link rel="author" title="JunChen Xia" href="mailto:xjconlyme@gmail.com"> |
6 <script src="../../../../resources/testharness.js"></script> | 6 <script src="../../../../resources/testharness.js"></script> |
7 <script src="../../../../resources/testharnessreport.js"></script> | 7 <script src="../../../../resources/testharnessreport.js"></script> |
8 | 8 |
9 <div id="log"></div> | 9 <div id="log"></div> |
10 | 10 |
11 <script> | 11 <script> |
12 async_test(function () { | 12 async_test(function () { |
13 var http = new XMLHttpRequest(); | 13 var http = new XMLHttpRequest(); |
14 http.open("GET", "/images/blue96x96.png", true); | 14 http.open("GET", "/images/blue96x96.png", true); |
15 http.responseType = "blob"; | 15 http.responseType = "blob"; |
16 http.onloadend = this.step_func(function(evt) { | 16 http.onloadend = this.step_func(function(evt) { |
17 var blobURI = window.URL.createObjectURL(http.response); | 17 var blobURI = window.URL.createObjectURL(http.response); |
18 assert_true(http.response instanceof Blob, "XMLHttpRequest returns instanc
eof Blob"); | 18 assert_true(http.response instanceof Blob, "XMLHttpRequest returns instanc
eof Blob"); |
19 assert_equals(typeof blobURI, "string", "Blob URI is typeof string"); | 19 assert_equals(typeof blobURI, "string", "Blob URI is typeof string"); |
20 assert_equals(blobURI.indexOf("blob"), 0, "Blob URI starts with 'blob'"); | 20 assert_equals(blobURI.indexOf("blob"), 0, "Blob URI starts with 'blob'"); |
21 assert_equals(http.status, 200, "The status is 200"); | 21 assert_equals(http.status, 200, "The status is 200"); |
22 assert_equals(http.statusText, "OK", "The status text is OK when XMLHttpRe
quest returns correct blob"); | 22 assert_equals(http.statusText, "OK", "The status text is OK when XMLHttpRe
quest returns correct blob"); |
23 assert_equals(http.getResponseHeader("Content-Type"), "image/png", "The co
ntent type is image/png when set the respnose blob"); | 23 assert_equals(http.getResponseHeader("Content-Type"), "image/png", "The co
ntent type is image/png when set the respnose blob"); |
24 this.done(); | 24 this.done(); |
25 }); | 25 }); |
26 http.send(); | 26 http.send(); |
27 }); | 27 }); |
28 </script> | 28 </script> |
29 | 29 |
OLD | NEW |