I’m now refactoring my add-on from base64 images to blobs and I noticed some strange behavior - in Chrome - where sending blobs through internal messaging doesn’t work (blob gets converted to empty object).
Then I checked the MDN:
Which says that the message is:
An object that can be serialized to JSON.
I’m pretty sure blob cannot be serialized to JSON.
Blobs certainly can’t be represented directly in JSON.
I hope that neither browser actually used JSON, as it is a rather indifferent format.
Firefox may be using something that encodes blobs, which is nice, but should be documented (in the compatibility table, I guess).
In other browsers you can either use base64 or URL.createObhectURL and fetch().blob().
But the latter probably doesn’t work when sending from content scripts and, depending on how you convert to base64, will only be more efficient from a certain size onwards.