Re: Request for approval of btoa()/atob() tests

On Sat, Apr 2, 2011 at 11:25 AM, Ms2ger <ms2ger@gmail.com> wrote:
> function stringRep(val) { ... }
>
> Could you expose format_value in testharness.js and use that instead?

Done, in r310 (37873a35a41b).

> mybtoa:
>
>    out += btoaLookup( ((s.charCodeAt(i) & 0x03) << 4) |
>                        (s.charCodeAt(i + 1) >> 4) );
>    if (i + 1 < s.length) {
>      out += btoaLookup( ((s.charCodeAt(i + 1) & 0x0f) << 2) |
>                          (s.charCodeAt(i + 2) >> 6) );
>    } else {
>      out += '=';
>    }
>    if (i + 2 < s.length) {
>      out += btoaLookup(s.charCodeAt(i + 2) & 0x3f);
>    } else {
>      out += '=';
>    }
>
> I note that you're relying on s.charCodeAt(s.length) >> n === 0. It might be
> good to note that in a comment (or not do that).

Oops, that was unintended.  I fixed it (also in r310), and hopefully
made the code clearer at the same time.

> I also note that you don't actually test JS value -> DOMString conversion,
> just that it matches String(), which will be a problem once you test null.

The current WebIDL spec says JS value -> DOMString is just calling
ToString() (which is the same as String(), right?), if there are no
special flags being used:

http://dev.w3.org/2006/webapi/WebIDL/#es-DOMString

This is wrong as far as null goes, but the spec doesn't say that yet,
so I avoided testing null.  When WebIDL is fixed, we can fix the
tests, but otherwise we'd be testing something contrary to the spec.

> No other comments, test approved.

Thanks.

Received on Sunday, 3 April 2011 18:15:07 UTC