tor-browser

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

test_databaseWorkStarted.js (1044B)


      1 /**
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/publicdomain/zero/1.0/
      4 */
      5 
      6 const { PrincipalUtils } = ChromeUtils.importESModule(
      7  "resource://testing-common/dom/quota/test/modules/PrincipalUtils.sys.mjs"
      8 );
      9 const { TestUtils } = ChromeUtils.importESModule(
     10  "resource://testing-common/TestUtils.sys.mjs"
     11 );
     12 
     13 add_task(async function testSteps() {
     14  const principal = PrincipalUtils.createPrincipal("https://example.com");
     15  const name = "test_databaseWorkStarted.js";
     16 
     17  info("Starting database opening");
     18 
     19  const openPromise = new Promise(function (resolve, reject) {
     20    const sandbox = new Cu.Sandbox(principal, {
     21      wantGlobalProperties: ["caches"],
     22    });
     23    sandbox.resolve = resolve;
     24    sandbox.reject = reject;
     25    Cu.evalInSandbox(`caches.open("${name}").then(resolve, reject);`, sandbox);
     26  });
     27 
     28  info("Waiting for database work to start");
     29 
     30  await TestUtils.topicObserved("CacheAPI::DatabaseWorkStarted");
     31 
     32  info("Waiting for database to finish opening");
     33 
     34  await openPromise;
     35 });