fune/testing/web-platform/tests/FileAPI/reading-data-section/filereader_readAsDataURL.any.js
Dean Leitersdorf 862a42a38f Bug 1832658 [wpt PR 39968] - Fixes crbug.com/1439823 by allowing empty strings to be processed in ToDataURL in file_reader_data.cc., a=testonly
Automatic update from web-platform-tests
Fixes crbug.com/1439823 by allowing empty strings to be processed in
ToDataURL in file_reader_data.cc.

Bug: 1439823
Change-Id: Ic2ec3fe20cd30c9d72e4e2dee9665f4a75d26c42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4522437
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Commit-Queue: Ayu Ishii <ayui@chromium.org>
Auto-Submit: Dean Leitersdorf <dean.leitersdorf@gmail.com>
Cr-Commit-Position: refs/heads/main@{#1146061}

--

wpt-commits: e36dbb6f00fb59f9fc792f509194432e9e6d0b6d
wpt-pr: 39968
2023-05-25 08:22:14 +00:00

54 lines
No EOL
1.6 KiB
JavaScript

// META: title=FileAPI Test: FileReader.readAsDataURL
async_test(function(testCase) {
var blob = new Blob(["TEST"]);
var reader = new FileReader();
reader.onload = this.step_func(function(evt) {
assert_equals(reader.readyState, reader.DONE);
testCase.done();
});
reader.onloadstart = this.step_func(function(evt) {
assert_equals(reader.readyState, reader.LOADING);
});
reader.onprogress = this.step_func(function(evt) {
assert_equals(reader.readyState, reader.LOADING);
});
reader.readAsDataURL(blob);
}, 'FileReader readyState during readAsDataURL');
async_test(function(testCase) {
var blob = new Blob(["TEST"], { type: 'text/plain' });
var reader = new FileReader();
reader.onload = this.step_func(function() {
assert_equals(reader.result, "data:text/plain;base64,VEVTVA==");
testCase.done();
});
reader.readAsDataURL(blob);
}, 'readAsDataURL result for Blob with specified MIME type');
async_test(function(testCase) {
var blob = new Blob(["TEST"]);
var reader = new FileReader();
reader.onload = this.step_func(function() {
assert_equals(reader.result,
"data:application/octet-stream;base64,VEVTVA==");
testCase.done();
});
reader.readAsDataURL(blob);
}, 'readAsDataURL result for Blob with unspecified MIME type');
async_test(function(testCase) {
var blob = new Blob([]);
var reader = new FileReader();
reader.onload = this.step_func(function() {
assert_equals(reader.result,
"data:application/octet-stream;base64,");
testCase.done();
});
reader.readAsDataURL(blob);
}, 'readAsDataURL result for empty Blob');