url_createobjecturl_file-manual.html (1349B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>FileAPI Test: Creating Blob URL with File</title> 4 <link rel="author" title="Intel" href="http://www.intel.com"> 5 <link rel="author" title="JunChen Xia" href="mailto:xjconlyme@gmail.com"> 6 <meta name="timeout" content="long"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 10 <div> 11 <p>Test steps:</p> 12 <ol> 13 <li>Download <a href="/images/blue96x96.png">blue96x96.png</a> to local.</li> 14 <li>Select the local file (blue96x96.png) to run the test.</li> 15 </ol> 16 </div> 17 18 <form name="uploadData"> 19 <input type="file" id="fileChooser"> 20 </form> 21 22 <div id="log"></div> 23 24 <script> 25 async_test(function(t) { 26 var fileInput = document.querySelector('#fileChooser'); 27 28 fileInput.onchange = t.step_func(function(e) { 29 var blobURL, file = fileInput.files[0]; 30 31 test(function() { 32 assert_true(file instanceof File, "FileList contains File"); 33 }, "Check if FileList contains File"); 34 35 test(function() { 36 blobURL = window.URL.createObjectURL(file); 37 assert_equals(typeof blobURL, "string", "Blob URL is type of string"); 38 assert_equals(blobURL.indexOf("blob"), 0, "Blob URL's scheme is blob"); 39 }, "Check if URL.createObjectURL(File) returns a Blob URL"); 40 41 t.done(); 42 }); 43 }); 44 </script>