You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
readAsDataURL should be more precise about the data URL contents #104
Re: "creating the string from the contents of the type attribute" - just a note in case someone tackles this. Beware of the gotcha associated with #43 - namely, as the spec is currently written, the value returned by the type attribute's getter and the internal type of the blob (which isn't clearly documented) differ if the type is not a parseable MIME type.
Though, saying that - it's not clear whether the mime type should fall back to that as well for a mime type which is parsable or not.
Based on the following test, I think the logic is probably just if it is not an empty string in all browsers at least:
async_test(function(testCase){varblob=newBlob(["TEST"],{type: 'not a mime type'});varreader=newFileReader();reader.onload=this.step_func(function(){assert_equals(reader.result,"data:not a mime type;base64,VEVTVA==");testCase.done();});reader.readAsDataURL(blob);},'readAsDataURL result for Blob with unparsable MIME type');
Activity
annevk commentedon Jun 21, 2018
See also whatwg/fetch#665 which this would tie into (if someone wants to work on that, feel free, happy to assist).
inexorabletash commentedon Jun 21, 2018
Re: "creating the string from the contents of the
typeattribute" - just a note in case someone tackles this. Beware of the gotcha associated with #43 - namely, as the spec is currently written, the value returned by thetypeattribute's getter and the internal type of the blob (which isn't clearly documented) differ if the type is not a parseable MIME type.shannonbooth commentedon Apr 8, 2026
Regarding the mime type, WPT tests that an unspecified mime type should be application/octet-stream which all browser implementations have aligned on.
https://github.com/web-platform-tests/wpt/blob/844e3e5ec7d746c04c8aabb5ab5e8e3732ce732c/FileAPI/reading-data-section/filereader_readAsDataURL.any.js#L42
shannonbooth commentedon Apr 8, 2026
Though, saying that - it's not clear whether the mime type should fall back to that as well for a mime type which is parsable or not.
Based on the following test, I think the logic is probably just if it is not an empty string in all browsers at least:
annevk commentedon Apr 9, 2026
There's a separate issue on making sure
typeis always valid. We should really attempt to fix that.