tor-browser

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

test_quotaClientInteractions.js (2027B)


      1 /**
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/publicdomain/zero/1.0/
      4 */
      5 
      6 const { IndexedDBUtils } = ChromeUtils.importESModule(
      7  "resource://testing-common/dom/indexedDB/test/modules/IndexedDBUtils.sys.mjs"
      8 );
      9 const { LocalStorageUtils } = ChromeUtils.importESModule(
     10  "resource://testing-common/dom/localstorage/test/modules/LocalStorageUtils.sys.mjs"
     11 );
     12 const { PrincipalUtils } = ChromeUtils.importESModule(
     13  "resource://testing-common/dom/quota/test/modules/PrincipalUtils.sys.mjs"
     14 );
     15 const { QuotaUtils } = ChromeUtils.importESModule(
     16  "resource://testing-common/dom/quota/test/modules/QuotaUtils.sys.mjs"
     17 );
     18 
     19 async function testNonExistentOriginDirectory() {
     20  const principal = PrincipalUtils.createPrincipal("https://example.com");
     21  const name = "test_quotaClientInteractions.js";
     22  const objectStoreName = "foo";
     23 
     24  info("Opening LocalStorage database");
     25 
     26  {
     27    const storage = LocalStorageUtils.createStorage(principal);
     28    storage.open();
     29  }
     30 
     31  info("Opening IndexedDB database");
     32 
     33  {
     34    const request = indexedDB.openForPrincipal(principal, name);
     35    request.onupgradeneeded = function (event) {
     36      const database = event.target.result;
     37      database.createObjectStore(objectStoreName);
     38    };
     39    const database = await IndexedDBUtils.requestFinished(request);
     40    database.close();
     41  }
     42 
     43  info("Resetting storage");
     44 
     45  {
     46    const request = Services.qms.reset();
     47    await QuotaUtils.requestFinished(request);
     48  }
     49 
     50  info("Opening LocalStorage database");
     51 
     52  {
     53    const storage = LocalStorageUtils.createStorage(principal);
     54    storage.open();
     55  }
     56 
     57  info("Deleting IndexedDB database");
     58 
     59  {
     60    const request = indexedDB.deleteForPrincipal(principal, name);
     61    await IndexedDBUtils.requestFinished(request);
     62  }
     63 }
     64 
     65 /* exported testSteps */
     66 async function testSteps() {
     67  add_task(
     68    {
     69      pref_set: [
     70        ["dom.storage.testing", true],
     71        ["dom.storage.client_validation", false],
     72      ],
     73    },
     74    testNonExistentOriginDirectory
     75  );
     76 }