tor-browser

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

head_libPrefs.js (1080B)


      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 const NS_APP_USER_PROFILE_50_DIR = "ProfD";
      6 
      7 function do_check_throws(f, result, stack) {
      8  if (!stack) {
      9    stack = Components.stack.caller;
     10  }
     11 
     12  try {
     13    f();
     14  } catch (exc) {
     15    equal(exc.result, result, "Correct exception was thrown");
     16    return;
     17  }
     18  ok(false, "expected result " + result + ", none thrown");
     19 }
     20 
     21 // Register current test directory as provider for the profile directory.
     22 var provider = {
     23  getFile(prop, persistent) {
     24    persistent.value = true;
     25    if (prop == NS_APP_USER_PROFILE_50_DIR) {
     26      return Services.dirsvc.get("CurProcD", Ci.nsIFile);
     27    }
     28    throw Components.Exception(
     29      "Tried to get test directory '" + prop + "'",
     30      Cr.NS_ERROR_FAILURE
     31    );
     32  },
     33  QueryInterface: ChromeUtils.generateQI(["nsIDirectoryServiceProvider"]),
     34 };
     35 Services.dirsvc
     36  .QueryInterface(Ci.nsIDirectoryService)
     37  .registerProvider(provider);