chrome/test/unit/test_bug848297.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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