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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | var MANIFESTS = [ |
michael@0 | 7 | do_get_file("data/test_bug848297.manifest") |
michael@0 | 8 | ]; |
michael@0 | 9 | |
michael@0 | 10 | // Stub in the locale service so we can control what gets returned as the OS locale setting |
michael@0 | 11 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 12 | |
michael@0 | 13 | registerManifests(MANIFESTS); |
michael@0 | 14 | |
michael@0 | 15 | var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"] |
michael@0 | 16 | .getService(Ci.nsIXULChromeRegistry) |
michael@0 | 17 | .QueryInterface(Ci.nsIToolkitChromeRegistry); |
michael@0 | 18 | chromeReg.checkForNewChrome(); |
michael@0 | 19 | |
michael@0 | 20 | var prefService = Cc["@mozilla.org/preferences-service;1"] |
michael@0 | 21 | .getService(Ci.nsIPrefService) |
michael@0 | 22 | .QueryInterface(Ci.nsIPrefBranch); |
michael@0 | 23 | |
michael@0 | 24 | function enum_to_array(strings) { |
michael@0 | 25 | let rv = []; |
michael@0 | 26 | while (strings.hasMore()) { |
michael@0 | 27 | rv.push(strings.getNext()); |
michael@0 | 28 | } |
michael@0 | 29 | rv.sort(); |
michael@0 | 30 | return rv; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | function run_test() { |
michael@0 | 34 | |
michael@0 | 35 | // without override |
michael@0 | 36 | prefService.setCharPref("general.useragent.locale", "de"); |
michael@0 | 37 | do_check_eq(chromeReg.getSelectedLocale("basepack"), "en-US"); |
michael@0 | 38 | do_check_eq(chromeReg.getSelectedLocale("overpack"), "de"); |
michael@0 | 39 | do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")), |
michael@0 | 40 | ['en-US', 'fr']); |
michael@0 | 41 | |
michael@0 | 42 | // with override |
michael@0 | 43 | prefService.setCharPref("chrome.override_package.basepack", "overpack"); |
michael@0 | 44 | do_check_eq(chromeReg.getSelectedLocale("basepack"), "de"); |
michael@0 | 45 | do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")), |
michael@0 | 46 | ['de', 'en-US']); |
michael@0 | 47 | |
michael@0 | 48 | } |