chrome/test/unit/test_bug848297.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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/.
     4  */
     6 var MANIFESTS = [
     7   do_get_file("data/test_bug848297.manifest")
     8 ];
    10 // Stub in the locale service so we can control what gets returned as the OS locale setting
    11 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
    13 registerManifests(MANIFESTS);
    15 var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
    16                 .getService(Ci.nsIXULChromeRegistry)
    17                 .QueryInterface(Ci.nsIToolkitChromeRegistry);
    18 chromeReg.checkForNewChrome();
    20 var prefService = Cc["@mozilla.org/preferences-service;1"]
    21                   .getService(Ci.nsIPrefService)
    22                   .QueryInterface(Ci.nsIPrefBranch);
    24 function enum_to_array(strings) {
    25   let rv = [];
    26   while (strings.hasMore()) {
    27     rv.push(strings.getNext());
    28   }
    29   rv.sort();
    30   return rv;
    31 }
    33 function run_test() {
    35   // without override
    36   prefService.setCharPref("general.useragent.locale", "de");
    37   do_check_eq(chromeReg.getSelectedLocale("basepack"), "en-US");
    38   do_check_eq(chromeReg.getSelectedLocale("overpack"), "de");
    39   do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")),
    40                    ['en-US', 'fr']);
    42   // with override
    43   prefService.setCharPref("chrome.override_package.basepack", "overpack");
    44   do_check_eq(chromeReg.getSelectedLocale("basepack"), "de");
    45   do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")),
    46                    ['de', 'en-US']);
    48 }

mercurial