tor-browser

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

browser_backgroundtask_purgeHTTPCache.js (1346B)


      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 "use strict";
      6 
      7 add_task(async function test_startupCleanup() {
      8  Services.prefs.setBoolPref(
      9    "network.cache.shutdown_purge_in_background_task",
     10    true
     11  );
     12  Services.prefs.setBoolPref("privacy.clearOnShutdown.cache", true);
     13  Services.prefs.setBoolPref("privacy.sanitize.sanitizeOnShutdown", true);
     14  let dir = Services.dirsvc.get("ProfD", Ci.nsIFile);
     15  dir.append("cache2.2021-11-25-08-47-04.purge.bg_rm");
     16  Assert.equal(dir.exists(), false, `Folder ${dir.path} should not exist`);
     17  dir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o744);
     18  Assert.equal(
     19    dir.exists(),
     20    true,
     21    `Folder ${dir.path} should have been created`
     22  );
     23 
     24  Services.obs.notifyObservers(null, "browser-delayed-startup-finished");
     25 
     26  await TestUtils.waitForCondition(() => {
     27    return !dir.exists();
     28  });
     29 
     30  Assert.equal(
     31    dir.exists(),
     32    false,
     33    `Folder ${dir.path} should have been purged by background task`
     34  );
     35  Services.prefs.clearUserPref(
     36    "network.cache.shutdown_purge_in_background_task"
     37  );
     38  Services.prefs.clearUserPref("privacy.clearOnShutdown.cache");
     39  Services.prefs.clearUserPref("privacy.sanitize.sanitizeOnShutdown");
     40 });