tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_osPreferences.js (1571B)


      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/. */
      4 
      5 function run_test() {
      6  const osprefs = Cc["@mozilla.org/intl/ospreferences;1"].getService(
      7    Ci.mozIOSPreferences
      8  );
      9 
     10  const systemLocale = osprefs.systemLocale;
     11  Assert.notEqual(systemLocale, "", "systemLocale is non-empty");
     12 
     13  const systemLocales = osprefs.systemLocales;
     14  Assert.ok(Array.isArray(systemLocales), "systemLocales returns an array");
     15 
     16  Assert.equal(
     17    systemLocale,
     18    systemLocales[0],
     19    "systemLocale matches first entry in systemLocales"
     20  );
     21 
     22  const rgLocales = osprefs.regionalPrefsLocales;
     23  Assert.ok(Array.isArray(rgLocales), "regionalPrefsLocales returns an array");
     24 
     25  const getDateTimePatternTests = [
     26    [osprefs.dateTimeFormatStyleNone, osprefs.dateTimeFormatStyleNone, ""],
     27    [osprefs.dateTimeFormatStyleShort, osprefs.dateTimeFormatStyleNone, ""],
     28    [osprefs.dateTimeFormatStyleNone, osprefs.dateTimeFormatStyleLong, "ar"],
     29    [osprefs.dateTimeFormatStyleFull, osprefs.dateTimeFormatStyleMedium, "ru"],
     30  ];
     31 
     32  for (let i = 0; i < getDateTimePatternTests.length; i++) {
     33    const test = getDateTimePatternTests[i];
     34 
     35    const pattern = osprefs.getDateTimePattern(...test);
     36    if (
     37      test[0] !== osprefs.dateTimeFormatStyleNone &&
     38      test[1] !== osprefs.dateTImeFormatStyleNone
     39    ) {
     40      Assert.greater(pattern.length, 0, "pattern is not empty.");
     41    }
     42  }
     43 
     44  Assert.ok(1, "osprefs didn't crash");
     45 }