11cb0ef41Sopenharmony_ci<!doctype html> 21cb0ef41Sopenharmony_ci<meta charset="utf-8"> 31cb0ef41Sopenharmony_ci<title>FileAPI Test: FileReader.readAsDataURL</title> 41cb0ef41Sopenharmony_ci<link rel="author" title="Intel" href="http://www.intel.com"> 51cb0ef41Sopenharmony_ci<link rel="help" href="https://w3c.github.io/FileAPI/#readAsDataURL"> 61cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script> 71cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script> 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci<script> 101cb0ef41Sopenharmony_ciasync_test(function(testCase) { 111cb0ef41Sopenharmony_ci var blob = new Blob(["TEST"]); 121cb0ef41Sopenharmony_ci var reader = new FileReader(); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci reader.onload = this.step_func(function(evt) { 151cb0ef41Sopenharmony_ci assert_equals(reader.readyState, reader.DONE); 161cb0ef41Sopenharmony_ci testCase.done(); 171cb0ef41Sopenharmony_ci }); 181cb0ef41Sopenharmony_ci reader.onloadstart = this.step_func(function(evt) { 191cb0ef41Sopenharmony_ci assert_equals(reader.readyState, reader.LOADING); 201cb0ef41Sopenharmony_ci }); 211cb0ef41Sopenharmony_ci reader.onprogress = this.step_func(function(evt) { 221cb0ef41Sopenharmony_ci assert_equals(reader.readyState, reader.LOADING); 231cb0ef41Sopenharmony_ci }); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci reader.readAsDataURL(blob); 261cb0ef41Sopenharmony_ci}, 'FileReader readyState during readAsDataURL'); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ciasync_test(function(testCase) { 291cb0ef41Sopenharmony_ci var blob = new Blob(["TEST"], { type: 'text/plain' }); 301cb0ef41Sopenharmony_ci var reader = new FileReader(); 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci reader.onload = this.step_func(function() { 331cb0ef41Sopenharmony_ci assert_equals(reader.result, "data:text/plain;base64,VEVTVA=="); 341cb0ef41Sopenharmony_ci testCase.done(); 351cb0ef41Sopenharmony_ci }); 361cb0ef41Sopenharmony_ci reader.readAsDataURL(blob); 371cb0ef41Sopenharmony_ci}, 'readAsDataURL result for Blob with specified MIME type'); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ciasync_test(function(testCase) { 401cb0ef41Sopenharmony_ci var blob = new Blob(["TEST"]); 411cb0ef41Sopenharmony_ci var reader = new FileReader(); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci reader.onload = this.step_func(function() { 441cb0ef41Sopenharmony_ci assert_equals(reader.result, 451cb0ef41Sopenharmony_ci "data:application/octet-stream;base64,VEVTVA=="); 461cb0ef41Sopenharmony_ci testCase.done(); 471cb0ef41Sopenharmony_ci }); 481cb0ef41Sopenharmony_ci reader.readAsDataURL(blob); 491cb0ef41Sopenharmony_ci}, 'readAsDataURL result for Blob with unspecified MIME type'); 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ciasync_test(function(testCase) { 521cb0ef41Sopenharmony_ci var blob = new Blob([]); 531cb0ef41Sopenharmony_ci var reader = new FileReader(); 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci reader.onload = this.step_func(function() { 561cb0ef41Sopenharmony_ci assert_equals(reader.result, 571cb0ef41Sopenharmony_ci "data:application/octet-stream;base64,"); 581cb0ef41Sopenharmony_ci testCase.done(); 591cb0ef41Sopenharmony_ci }); 601cb0ef41Sopenharmony_ci reader.readAsDataURL(blob); 611cb0ef41Sopenharmony_ci}, 'readAsDataURL result for empty Blob'); 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci</script> 64