Bug 55663 - Implement btoa and atob functions in Web Workers
Summary: Implement btoa and atob functions in Web Workers
Status: RESOLVED DUPLICATE of bug 158576
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Enhancement
Assignee: Nobody
Depends on:
Reported: 2011-03-03 04:40 PST by Jon Leighton
Modified: 2016-06-09 15:44 PDT (History)
7 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Jon Leighton 2011-03-03 04:40:54 PST
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.
Comment 1 Alexey Proskuryakov 2011-03-03 14:38:58 PST
Could you please provide some use cases for using these functions in workers?
Comment 2 Jon Leighton 2011-03-03 15:07:18 PST
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.
Comment 3 Eric 2012-08-17 15:33:22 PDT
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
Comment 4 popecode 2013-09-23 21:15:31 PDT
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.
Comment 5 Dmitry Chestnykh 2014-12-13 06:13:57 PST
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.

Comment 6 Mathias Bynens 2014-12-13 09:23:06 PST
@Dmitry, as a workaround you can use a fully `btoa`/`atob`-compatible polyfill like https://github.com/mathiasbynens/base64.
Comment 7 Chris Dumez 2016-06-09 15:44:09 PDT

*** This bug has been marked as a duplicate of bug 158576 ***