Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /**
6 * Test bug 448344 to make sure when we're in low minutes, we show both minutes
7 * and seconds; but continue to show only minutes when we have plenty.
8 */
10 Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
12 /**
13 * Print some debug message to the console. All arguments will be printed,
14 * separated by spaces.
15 *
16 * @param [arg0, arg1, arg2, ...]
17 * Any number of arguments to print out
18 * @usage _("Hello World") -> prints "Hello World"
19 * @usage _(1, 2, 3) -> prints "1 2 3"
20 */
21 let _ = function(some, debug, text, to) print(Array.slice(arguments).join(" "));
23 _("Make an array of time lefts and expected string to be shown for that time");
24 let expectedTimes = [
25 [1.1, "A few seconds remaining", "under 4sec -> few"],
26 [2.5, "A few seconds remaining", "under 4sec -> few"],
27 [3.9, "A few seconds remaining", "under 4sec -> few"],
28 [5.3, "5 seconds remaining", "truncate seconds"],
29 [1.1 * 60, "1 minute, 6 seconds remaining", "under 4min -> show sec"],
30 [2.5 * 60, "2 minutes, 30 seconds remaining", "under 4min -> show sec"],
31 [3.9 * 60, "3 minutes, 54 seconds remaining", "under 4min -> show sec"],
32 [5.3 * 60, "5 minutes remaining", "over 4min -> only show min"],
33 [1.1 * 3600, "1 hour, 6 minutes remaining", "over 1hr -> show min/sec"],
34 [2.5 * 3600, "2 hours, 30 minutes remaining", "over 1hr -> show min/sec"],
35 [3.9 * 3600, "3 hours, 54 minutes remaining", "over 1hr -> show min/sec"],
36 [5.3 * 3600, "5 hours, 18 minutes remaining", "over 1hr -> show min/sec"],
37 ];
38 _(expectedTimes.join("\n"));
40 function run_test()
41 {
42 expectedTimes.forEach(function([time, expectStatus, comment]) {
43 _("Running test with time", time);
44 _("Test comment:", comment);
45 let [status, last] = DownloadUtils.getTimeLeft(time);
47 _("Got status:", status, "last:", last);
48 _("Expecting..", expectStatus);
49 do_check_eq(status, expectStatus);
51 _();
52 });
53 }