--- a/toolkit/mozapps/downloads/tests/unit/test_DownloadUtils.js
+++ b/toolkit/mozapps/downloads/tests/unit/test_DownloadUtils.js
@@ -34,17 +34,17 @@
*
* ***** END LICENSE BLOCK ***** */
let Cu = Components.utils;
Cu.import("resource://gre/modules/DownloadUtils.jsm");
const gDecimalSymbol = Number(5.4).toLocaleString().match(/\D/);
function _(str) {
- return str.replace(".", gDecimalSymbol);
+ return str.replace(".", gDecimalSymbol, "g");
}
function testConvertByteUnits(aBytes, aValue, aUnit)
{
let [value, unit] = DownloadUtils.convertByteUnits(aBytes);
do_check_eq(value, aValue);
do_check_eq(unit, aUnit);
}
@@ -71,17 +71,17 @@ function testStatus(aCurr, aMore, aRate,
DownloadUtils.getDownloadStatus(curr, max, speed);
if (0) {
dump("testStatus(" + aCurr + ", " + aMore + ", " + aRate + ", [\"" +
status.replace(gDash, "--") + "\", " + last.toFixed(3) + "]);\n");
}
// Make sure the status text matches
- do_check_eq(status, aTest[0].replace(/--/, gDash));
+ do_check_eq(status, _(aTest[0].replace(/--/, gDash)));
// Make sure the lastSeconds matches
if (last == Infinity)
do_check_eq(last, aTest[1]);
else
do_check_true(Math.abs(last - aTest[1]) < .1);
}
@@ -108,16 +108,17 @@ function run_test()
testConvertByteUnits(640000, _("625"), "KB");
testConvertByteUnits(1048576, _("1.0"), "MB");
testConvertByteUnits(307232768, _("293"), "MB");
testConvertByteUnits(1073741824, _("1.0"), "GB");
testTransferTotal(1, 1, _("1 of 1 bytes"));
testTransferTotal(234, 4924, _("234 bytes of 4.8 KB"));
testTransferTotal(94923, 233923, _("92.7 of 228 KB"));
+ testTransferTotal(4924, 94923, _("4.8 of 92.7 KB"));
testTransferTotal(2342, 294960345, _("2.3 KB of 281 MB"));
testTransferTotal(234, undefined, _("234 bytes"));
testTransferTotal(4889023, undefined, _("4.7 MB"));
if (0) {
// Help find some interesting test cases
let r = function() Math.floor(Math.random() * 10);
for (let i = 0; i < 100; i++) {