tor-browser

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

test_unsetLastAccessTime.js (1947B)


      1 /**
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/publicdomain/zero/1.0/
      4 */
      5 
      6 async function testSteps() {
      7  const metadataFile = getRelativeFile(
      8    "storage/default/https+++foo.example.com/.metadata-v2"
      9  );
     10 
     11  function getLastAccessTime() {
     12    let fileInputStream = Cc[
     13      "@mozilla.org/network/file-input-stream;1"
     14    ].createInstance(Ci.nsIFileInputStream);
     15 
     16    fileInputStream.init(metadataFile, -1, -1, 0);
     17 
     18    let binaryInputStream = Cc[
     19      "@mozilla.org/binaryinputstream;1"
     20    ].createInstance(Ci.nsIBinaryInputStream);
     21 
     22    binaryInputStream.setInputStream(fileInputStream);
     23 
     24    let lastAccessTime = BigInt.asIntN(64, BigInt(binaryInputStream.read64()));
     25 
     26    binaryInputStream.close();
     27 
     28    return lastAccessTime;
     29  }
     30 
     31  info("Clearing");
     32 
     33  let request = clear();
     34  await requestFinished(request);
     35 
     36  info("Installing package");
     37 
     38  // The profile contains one initialized origin directory and the storage
     39  // database:
     40  // - storage/default/https+++foo.example.com
     41  // - storage.sqlite
     42  // The file make_unsetLastAccessTime.js was run locally, specifically it was
     43  // temporarily enabled in xpcshell.toml and then executed:
     44  // mach test --interactive dom/quota/test/xpcshell/make_unsetLastAccessTime.js
     45  // Note: to make it become the profile in the test, additional manual steps
     46  // are needed.
     47  // 1. Remove the folder "storage/temporary".
     48  // 2. Remove the file "storage/ls-archive.sqlite".
     49  installPackage("unsetLastAccessTime_profile");
     50 
     51  info("Verifying last access time");
     52 
     53  Assert.equal(getLastAccessTime(), INT64_MIN, "Correct last access time");
     54 
     55  info("Initializing");
     56 
     57  request = init();
     58  await requestFinished(request);
     59 
     60  info("Initializing temporary storage");
     61 
     62  request = initTemporaryStorage();
     63  await requestFinished(request);
     64 
     65  info("Verifying last access time");
     66 
     67  Assert.notEqual(getLastAccessTime(), INT64_MIN, "Correct last access time");
     68 }