tor-browser

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

test_groupMismatch.js (2157B)


      1 /**
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/publicdomain/zero/1.0/
      4 */
      5 
      6 /**
      7 * This test is mainly to verify that metadata files with old group information
      8 * get updated. See bug 1535995.
      9 */
     10 
     11 loadScript("dom/quota/test/common/file.js");
     12 
     13 async function testSteps() {
     14  const metadataFile = getRelativeFile(
     15    "storage/default/https+++foo.bar.mozilla-iot.org/.metadata-v2"
     16  );
     17 
     18  async function readMetadataFile() {
     19    let file = await File.createFromNsIFile(metadataFile);
     20 
     21    let buffer = await new Promise(resolve => {
     22      let reader = new FileReader();
     23      reader.onloadend = () => resolve(reader.result);
     24      reader.readAsArrayBuffer(file);
     25    });
     26 
     27    return buffer;
     28  }
     29 
     30  info("Clearing");
     31 
     32  let request = clear();
     33  await requestFinished(request);
     34 
     35  info("Installing package");
     36 
     37  // The profile contains one initialized origin directory, a script for origin
     38  // initialization and the storage database:
     39  // - storage/default/https+++foo.bar.mozilla-iot.org
     40  // - create_db.js
     41  // - storage.sqlite
     42  // The file create_db.js in the package was run locally, specifically it was
     43  // temporarily added to xpcshell.toml and then executed:
     44  //   mach xpcshell-test --interactive dom/localstorage/test/xpcshell/create_db.js
     45  // Note: to make it become the profile in the test, additional manual steps
     46  // are needed.
     47  // 1. Manually change the group in .metadata and .metadata-v2 from
     48  //    "bar.mozilla-iot.org" to "mozilla-iot.org".
     49  // 2. Remove the folder "storage/temporary".
     50  // 3. Remove the file "storage/ls-archive.sqlite".
     51  installPackage("groupMismatch_profile");
     52 
     53  info("Reading out contents of metadata file");
     54 
     55  let metadataBuffer = await readMetadataFile();
     56 
     57  info("Initializing");
     58 
     59  request = init();
     60  await requestFinished(request);
     61 
     62  info("Initializing temporary storage");
     63 
     64  request = initTemporaryStorage();
     65  await requestFinished(request);
     66 
     67  info("Reading out contents of metadata file");
     68 
     69  let metadataBuffer2 = await readMetadataFile();
     70 
     71  info("Verifying blobs differ");
     72 
     73  ok(!compareBuffers(metadataBuffer, metadataBuffer2), "Metadata differ");
     74 }