tor-browser

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

prefs_test_common.js (1420B)


      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 isValidPref(prefName) {
      6  return Services.prefs.getPrefType(prefName) !== Services.prefs.PREF_INVALID;
      7 }
      8 
      9 // Check a pref that appears in testing/profiles/xpcshell/user.js
     10 // but NOT in StaticPrefList.yaml, modules/libpref/init/all.js
     11 function has_pref_from_xpcshell_user_js() {
     12  return isValidPref("extensions.webextensions.warnings-as-errors");
     13 }
     14 
     15 // Test pref from xpcshell-with-prefs.toml
     16 function has_pref_from_manifest_defaults() {
     17  return isValidPref("dummy.pref.from.test.manifest");
     18 }
     19 
     20 // Test pref set in xpcshell.toml and xpcshell-with-prefs.toml
     21 function has_pref_from_manifest_file_section() {
     22  return isValidPref("dummy.pref.from.test.file");
     23 }
     24 
     25 function check_common_xpcshell_with_prefs() {
     26  Assert.ok(
     27    has_pref_from_xpcshell_user_js(),
     28    "Should have pref from xpcshell's user.js"
     29  );
     30 
     31  Assert.ok(
     32    has_pref_from_manifest_defaults(),
     33    "Should have pref from DEFAULTS in xpcshell-with-prefs.toml"
     34  );
     35 }
     36 
     37 function check_common_xpcshell_without_prefs() {
     38  Assert.ok(
     39    has_pref_from_xpcshell_user_js(),
     40    "Should have pref from xpcshell's user.js"
     41  );
     42 
     43  Assert.ok(
     44    !has_pref_from_manifest_defaults(),
     45    "xpcshell.toml did not set any prefs in DEFAULTS"
     46  );
     47 }