tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

filereader_readAsDataURL.any.js (1647B)


      1 // META: title=FileAPI Test: FileReader.readAsDataURL
      2 
      3 async_test(function(testCase) {
      4  var blob = new Blob(["TEST"]);
      5  var reader = new FileReader();
      6 
      7  reader.onload = this.step_func(function(evt) {
      8    assert_equals(reader.readyState, reader.DONE);
      9    testCase.done();
     10  });
     11  reader.onloadstart = this.step_func(function(evt) {
     12    assert_equals(reader.readyState, reader.LOADING);
     13  });
     14  reader.onprogress = this.step_func(function(evt) {
     15    assert_equals(reader.readyState, reader.LOADING);
     16  });
     17 
     18  reader.readAsDataURL(blob);
     19 }, 'FileReader readyState during readAsDataURL');
     20 
     21 async_test(function(testCase) {
     22  var blob = new Blob(["TEST"], { type: 'text/plain' });
     23  var reader = new FileReader();
     24 
     25  reader.onload = this.step_func(function() {
     26    assert_equals(reader.result, "data:text/plain;base64,VEVTVA==");
     27    testCase.done();
     28  });
     29  reader.readAsDataURL(blob);
     30 }, 'readAsDataURL result for Blob with specified MIME type');
     31 
     32 async_test(function(testCase) {
     33  var blob = new Blob(["TEST"]);
     34  var reader = new FileReader();
     35 
     36  reader.onload = this.step_func(function() {
     37    assert_equals(reader.result,
     38                  "data:application/octet-stream;base64,VEVTVA==");
     39    testCase.done();
     40  });
     41  reader.readAsDataURL(blob);
     42 }, 'readAsDataURL result for Blob with unspecified MIME type');
     43 
     44 async_test(function(testCase) {
     45  var blob = new Blob([]);
     46  var reader = new FileReader();
     47 
     48  reader.onload = this.step_func(function() {
     49    assert_equals(reader.result,
     50                  "data:application/octet-stream;base64,");
     51    testCase.done();
     52  });
     53  reader.readAsDataURL(blob);
     54 }, 'readAsDataURL result for empty Blob');