Mozilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=688443 Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#atob It doesn't have [TreatNullAs=EmptyString], so it should be treated as "null". No one does this currently for btoa() or atob() -- Firefox 8.0a2, Chrome 15 dev, and Opera 11.50 stringify to "". (IE doesn't support the functions.) But it seems like consensus is that browsers should change here, not the spec: http://krijnhoetmer.nl/irc-logs/whatwg/20110922#l-230 (first two lines) http://krijnhoetmer.nl/irc-logs/whatwg/20110922#l-554 (continuation) zcorpan reports Opera has already changed, and Ms2ger says Gecko should change too. I'll update my base64 tests at the W3C to test for this.
Created attachment 118133 [details] Patch
Comment on attachment 118133 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=118133&action=review > Source/WebCore/page/DOMWindow.idl:252 > - DOMString btoa(in [ConvertNullToNullString,Optional=CallWithDefaultValue] DOMString string) > + DOMString btoa(in [ConvertNullStringTo=Null,Optional=CallWithDefaultValue] DOMString string) Can we just drop the attribute? What's the default value?
Created attachment 118190 [details] Patch
Firefox is currently throwing a TypeError with not enough arguments when atob() and btoa() is called with no arguments. My patch above should fix that as well.
Comment on attachment 118190 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=118190&action=review The change looks OK to me. > Source/WebCore/ChangeLog:5 > + Would you add some explanation about this change? At least the link to the spec, please. > LayoutTests/ChangeLog:5 > + Would you add some explanation about this change? At least the link to the spec, please. > LayoutTests/fast/dom/Window/atob-btoa.html:25 > +shouldBe('window.btoa(null)', '"bnVsbA=="'); > shouldBe('window.btoa(undefined)', '"dW5kZWZpbmVk"'); Shall we add the following test cases? shouldBe('window.btoa("null")', '"bnVsbA=="'); shouldBe('window.btoa("undefined")', '"dW5kZWZpbmVk"'); > LayoutTests/fast/dom/Window/atob-btoa.html:35 > shouldThrow('window.atob()'); // 'undefined' Can you remove the comment "// 'undefined'"? > LayoutTests/fast/dom/Window/atob-btoa.html:38 > +shouldBe('window.atob(null)', '"Âée"'); > shouldThrow('window.atob(undefined)'); Shall we add the following test cases? shouldBe('window.atob("null")', '"Âée"'); shouldThrow('window.atob("undefined")');
Comment on attachment 118190 [details] Patch r-, per Kentaro's comments.
(In reply to Alexander Færøy from comment #4) > Firefox is currently throwing a TypeError with not enough arguments when > atob() and btoa() is called with no arguments. My patch above should fix > that as well. Thank you for the patch! atob() / btoa() argument was made mandatory in r152859. *** This bug has been marked as a duplicate of bug 118844 ***