Firefox supports btoa() and atob() functions within workers, which do the same thing as window.btoa() and window.atob() in the DOM. It would be great if these were available in WebKit too.
Could you please provide some use cases for using these functions in workers?
In a project I was working on I was downloading image data via XHR in a Web Worker and then encoding it into a data: URI. (I say 'was' because I have since stopped doing it in a worker, for separate reasons, but there you go...)
I could imagine you might have, for example, a web-based email client which might want to encode a multipart message before sending it, all the background in a worker.
My use case is similar. I'm using GIFEncoder (https://github.com/antimatter15/jsgif/blob/master/GIFEncoder.js), in a worker to produce a data URL from of the encoded gif. GIFEncoder implements it's own encode64() method: https://github.com/antimatter15/jsgif/blob/master/Demos/b64.js
I wrote a frame buffer to handle image downloads from a worker thread. For my application, this is necessary as the main thread is handling a video and an animation and performance is critical.
To use the downloaded images in the browser, I first have to convert them via btoa(). Using firefox, I can perform this conversion before passing the data to the main thread. Since chrome does not allow this, Firefox runs significantly faster than Chrome in my case.
Is there any progress on this? I use atob/btoa for base64 encoding in TweetNaCl-js instead of implementing my own routines, and I'd like them to be available from web workers. FIY, both Firefox and Chrome have them.
@Dmitry, as a workaround you can use a fully `btoa`/`atob`-compatible polyfill like https://github.com/mathiasbynens/base64.
*** This bug has been marked as a duplicate of bug 158576 ***