diff --git a/.eslintignore b/.eslintignore index d10aa67a6645..cc303851bff2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -131,8 +131,6 @@ dom/workers/test/invalid.js dom/workers/test/threadErrors_worker1.js # intl/ exclusions -intl/locale/ -intl/strres/ intl/uconv/ # Bug 1527075: This directory is linted in github repository intl/l10n/ diff --git a/intl/locale/PluralForm.jsm b/intl/locale/PluralForm.jsm index 14596673ed51..cab11a492e3e 100644 --- a/intl/locale/PluralForm.jsm +++ b/intl/locale/PluralForm.jsm @@ -4,6 +4,8 @@ var EXPORTED_SYMBOLS = ["PluralForm"]; +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); + /** * This module provides the PluralForm object which contains a method to figure * out which plural form of a word to use for a given number based on the @@ -36,6 +38,7 @@ const kIntlProperties = "chrome://global/locale/intl.properties"; // These are the available plural functions that give the appropriate index // based on the plural rule number specified. The first element is the number // of plural forms and the second is the function to figure out the index. +/* eslint-disable no-nested-ternary */ var gFunctions = [ // 0: Chinese [1, n => 0], @@ -184,6 +187,7 @@ var gFunctions = [ : 2, ], ]; +/* eslint-enable no-nested-ternary */ var PluralForm = { /** @@ -290,8 +294,7 @@ var PluralForm = { */ get ruleNum() { return Number( - Cc["@mozilla.org/intl/stringbundle;1"] - .getService(Ci.nsIStringBundleService) + Services.strings .createBundle(kIntlProperties) .GetStringFromName("pluralRule") ); @@ -306,8 +309,6 @@ var PluralForm = { */ function log(aMsg) { let msg = "PluralForm.jsm: " + (aMsg.join ? aMsg.join("") : aMsg); - Cc["@mozilla.org/consoleservice;1"] - .getService(Ci.nsIConsoleService) - .logStringMessage(msg); + Services.console.logStringMessage(msg); dump(msg + "\n"); } diff --git a/intl/locale/tests/unit/test_localeService.js b/intl/locale/tests/unit/test_localeService.js index da09e77fc26d..1970ae94b260 100644 --- a/intl/locale/tests/unit/test_localeService.js +++ b/intl/locale/tests/unit/test_localeService.js @@ -7,9 +7,7 @@ const osPrefs = Cc["@mozilla.org/intl/ospreferences;1"].getService( Ci.mozIOSPreferences ); -const localeService = Cc["@mozilla.org/intl/localeservice;1"].getService( - Ci.mozILocaleService -); +const localeService = Services.locale; /** * Make sure the locale service can be instantiated. diff --git a/intl/locale/tests/unit/test_localeService_negotiateLanguages.js b/intl/locale/tests/unit/test_localeService_negotiateLanguages.js index 7f0fa63c62df..0cd27eb3bfc2 100644 --- a/intl/locale/tests/unit/test_localeService_negotiateLanguages.js +++ b/intl/locale/tests/unit/test_localeService_negotiateLanguages.js @@ -2,9 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -const localeService = Cc["@mozilla.org/intl/localeservice;1"].getService( - Ci.mozILocaleService -); +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const localeService = Services.locale; const data = { filtering: { @@ -148,10 +147,10 @@ function run_test() { const requested = test[0]; const available = test[1]; const defaultLocale = test.length > 3 ? test[2] : undefined; - const strategy = test.length > 4 ? test[3] : undefined; + const strategyInner = test.length > 4 ? test[3] : undefined; const supported = test[test.length - 1]; - const result = nl(test[0], test[1], defaultLocale, strategy); + const result = nl(test[0], test[1], defaultLocale, strategyInner); deepEqual( result, supported, diff --git a/intl/strres/tests/unit/test_bug378839.js b/intl/strres/tests/unit/test_bug378839.js index 8d216a1cc8c4..360e520761ef 100644 --- a/intl/strres/tests/unit/test_bug378839.js +++ b/intl/strres/tests/unit/test_bug378839.js @@ -1,6 +1,8 @@ /* Tests getting properties from string bundles */ +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); + const name_file = "file"; const value_file = "File"; @@ -27,11 +29,8 @@ const var_hello = "World"; const value_hello = "Hello World"; // tests formatStringFromName with parameter function run_test() { - var StringBundle = Cc["@mozilla.org/intl/stringbundle;1"].getService( - Ci.nsIStringBundleService - ); - var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); - var bundleURI = ios.newFileURI(do_get_file("strres.properties")); + var StringBundle = Services.strings; + var bundleURI = Services.io.newFileURI(do_get_file("strres.properties")); var bundle = StringBundle.createBundle(bundleURI.spec); diff --git a/intl/strres/tests/unit/test_bug397093.js b/intl/strres/tests/unit/test_bug397093.js index d9f27af1edf7..ccc9b5f2aa00 100644 --- a/intl/strres/tests/unit/test_bug397093.js +++ b/intl/strres/tests/unit/test_bug397093.js @@ -4,6 +4,8 @@ * all GetStringFromName calls should fail. */ +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); + const name_ascii = "asciiProperty"; const value_ascii = ""; @@ -14,11 +16,8 @@ const name_latin1 = "latin1"; const value_latin1 = ""; function run_test() { - var StringBundle = Cc["@mozilla.org/intl/stringbundle;1"].getService( - Ci.nsIStringBundleService - ); - var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); - var bundleURI = ios.newFileURI(do_get_file("397093.properties")); + var StringBundle = Services.strings; + var bundleURI = Services.io.newFileURI(do_get_file("397093.properties")); var bundle = StringBundle.createBundle(bundleURI.spec);