tor-browser

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

test_unexpectedDirectory.js (1597B)


      1 /**
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/publicdomain/zero/1.0/
      4 */
      5 
      6 function getTestingFiles() {
      7  const filenameBase = "unexpectedDirectory";
      8  let baseDir = getRelativeFile("storage/permanent/chrome/idb");
      9 
     10  let unexpectedDirWithoutSuffix = baseDir.clone();
     11  unexpectedDirWithoutSuffix.append(filenameBase);
     12 
     13  let unexpectedDir = baseDir.clone();
     14  unexpectedDir.append(filenameBase + ".files");
     15 
     16  return { unexpectedDirWithoutSuffix, unexpectedDir };
     17 }
     18 
     19 function createTestingEnvironment() {
     20  let testingFiles = getTestingFiles();
     21  testingFiles.unexpectedDir.create(
     22    Ci.nsIFile.DIRECTORY_TYPE,
     23    parseInt("0755", 8)
     24  );
     25 
     26  testingFiles.unexpectedDirWithoutSuffix.create(
     27    Ci.nsIFile.DIRECTORY_TYPE,
     28    parseInt("0755", 8)
     29  );
     30 }
     31 
     32 /**
     33 * This test verifies unexpected directories won't block idb's initialization.
     34 */
     35 
     36 /* exported testSteps */
     37 async function testSteps() {
     38  info("Verifying open shouldn't be blocked by unexpected files");
     39 
     40  createTestingEnvironment();
     41 
     42  let request = indexedDB.open(
     43    this.window ? window.location.pathname : "Splendid Test",
     44    1
     45  );
     46  await expectingUpgrade(request);
     47 
     48  // Waiting for a success event for indexedDB.open()
     49  let event = await expectingSuccess(request);
     50 
     51  let testingFiles = getTestingFiles();
     52  ok(
     53    !testingFiles.unexpectedDir.exists(),
     54    "The unexpected directory doesn't exist"
     55  );
     56  ok(
     57    !testingFiles.unexpectedDirWithoutSuffix.exists(),
     58    "The unexpected directory without the suffix doesn't exist"
     59  );
     60 
     61  let db = event.target.result;
     62  db.close();
     63 }