+2009-12-13 Eric Seidel <eric@webkit.org>
+
+ Reviewed by Gavin Barraclough.
+
+ string-base64 test does not compute a valid base64 string
+ http://bugs.webkit.org/show_bug.cgi?id=16806
+
+ * tests/string-base64.js: change str[i] to str.charCodeAt(i)
+
2009-12-10 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
Reviewed by Xan Lopez.
+2009-12-13 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Gavin Barraclough.
+
+ SunSpider/tests/string-base64.js does not compute a valid base64 encoded string
+ https://bugs.webkit.org/show_bug.cgi?id=16806
+
+ Based on a patch by Eric Seidel.
+
+ Fix the base64 computation to actually compute correct results. The impact on runtime of
+ the test is pretty small, but noticeable for some browsers. But at least it's not
+ doing a wrong and meaningless computation any more.
+
+ * tests/sunspider-0.9.1/string-base64.js:
+ ():
+ (base64ToString):
+
2009-12-13 Maciej Stachowiak <mjs@apple.com>
Fixing commit error...
var i;
// Convert every three bytes to 4 ascii characters.
for (i = 0; i < (length - 2); i += 3) {
- result += toBase64Table[data[i] >> 2];
- result += toBase64Table[((data[i] & 0x03) << 4) + (data[i+1] >> 4)];
- result += toBase64Table[((data[i+1] & 0x0f) << 2) + (data[i+2] >> 6)];
- result += toBase64Table[data[i+2] & 0x3f];
+ result += toBase64Table[data.charCodeAt(i) >> 2];
+ result += toBase64Table[((data.charCodeAt(i) & 0x03) << 4) + (data.charCodeAt(i+1) >> 4)];
+ result += toBase64Table[((data.charCodeAt(i+1) & 0x0f) << 2) + (data.charCodeAt(i+2) >> 6)];
+ result += toBase64Table[data.charCodeAt(i+2) & 0x3f];
}
// Convert the remaining 1 or 2 bytes, pad out to 4 characters.
if (length%3) {
i = length - (length%3);
- result += toBase64Table[data[i] >> 2];
+ result += toBase64Table[data.charCodeAt(i) >> 2];
if ((length%3) == 2) {
- result += toBase64Table[((data[i] & 0x03) << 4) + (data[i+1] >> 4)];
- result += toBase64Table[(data[i+1] & 0x0f) << 2];
+ result += toBase64Table[((data.charCodeAt(i) & 0x03) << 4) + (data.charCodeAt(i+1) >> 4)];
+ result += toBase64Table[(data.charCodeAt(i+1) & 0x0f) << 2];
result += base64Pad;
} else {
- result += toBase64Table[(data[i] & 0x03) << 4];
+ result += toBase64Table[(data.charCodeAt(i) & 0x03) << 4];
result += base64Pad + base64Pad;
}
}
// Convert one by one.
for (var i = 0; i < data.length; i++) {
var c = toBinaryTable[data.charCodeAt(i) & 0x7f];
- var padding = (data[i] == base64Pad);
+ var padding = (data.charCodeAt(i) == base64Pad.charCodeAt(0));
// Skip illegal characters and whitespace
if (c == -1) continue;