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.
michael@0 | 1 | String.prototype.has = function(s) this.indexOf(s) != -1; |
michael@0 | 2 | const Cc = Components.classes; |
michael@0 | 3 | const Ci = Components.interfaces; |
michael@0 | 4 | |
michael@0 | 5 | const dts = Cc["@mozilla.org/intl/scriptabledateformat;1"] |
michael@0 | 6 | .getService(Ci.nsIScriptableDateFormat); |
michael@0 | 7 | function dt(locale) dts.FormatDateTime(locale, dts.dateFormatLong, |
michael@0 | 8 | dts.timeFormatSeconds, 2008, 6, 30, 13, 56, 34); |
michael@0 | 9 | var all_passed = true; |
michael@0 | 10 | const tests = |
michael@0 | 11 | [ |
michael@0 | 12 | [dt("en-US").has("June"), "month name in en-US"], |
michael@0 | 13 | [dt("en-US").has("2008"), "year in en-US"], |
michael@0 | 14 | [dt("da").has("jun"), "month name in da"], |
michael@0 | 15 | [dt("da-DK") == dt("da"), "da same as da-DK"], |
michael@0 | 16 | [dt("en-GB").has("30") && dt("en-GB").has("June") && |
michael@0 | 17 | dt("en-GB").indexOf("30") < dt("en-GB").indexOf("June"), |
michael@0 | 18 | "day before month in en-GB"], |
michael@0 | 19 | [dt("en-US").has("30") && dt("en-US").has("June") && |
michael@0 | 20 | dt("en-US").indexOf("30") > dt("en-US").indexOf("June"), |
michael@0 | 21 | "month before day in en-US"], |
michael@0 | 22 | [dt("ja-JP").has("\u5E746\u670830\u65E5"), "year month and day in ja-JP"], |
michael@0 | 23 | [dt("ja-JP") == dt("ja-JP-mac"), "ja-JP-mac same as ja-JP"], |
michael@0 | 24 | [dt("nn-NO").has("juni"), "month name in nn-NO"], |
michael@0 | 25 | [dt("nb-NO").has("juni"), "month name in nb-NO"], |
michael@0 | 26 | [dt("no-NO").has("30. juni"), "month name in no-NO"], |
michael@0 | 27 | [dt("sv-SE").has("30 jun"), "month name in sv-SE"], |
michael@0 | 28 | [dt("kok").has("\u091C\u0942\u0928"), "month name in kok"], |
michael@0 | 29 | [dt("ta-IN").has("\u0B9C\u0BC2\u0BA9\u0BCD"), "month name in ta-IN"], |
michael@0 | 30 | [dt("ab-CD").length > 0, "fallback for ab-CD"] |
michael@0 | 31 | ]; |
michael@0 | 32 | |
michael@0 | 33 | function one_test(testcase, msg) |
michael@0 | 34 | { |
michael@0 | 35 | if (!testcase) { |
michael@0 | 36 | all_passed = false; |
michael@0 | 37 | dump("Unexpected date format: " + msg + "\n"); |
michael@0 | 38 | } |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function run_test() |
michael@0 | 42 | { |
michael@0 | 43 | for (var i = 0; i < tests.length; ++i) { |
michael@0 | 44 | one_test(tests[i][0], tests[i][1]); |
michael@0 | 45 | } |
michael@0 | 46 | do_check_true(all_passed); |
michael@0 | 47 | } |