tor-browser

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

test_locks.js (867B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 https://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Tests that privileged scopes can access Web Locks and use them without
      8 * being associated with a content global.
      9 */
     10 add_task(async function test_locks() {
     11  Assert.ok(locks, "The locks global was imported.");
     12  let { promise: firstPromise, resolve: firstResolve } =
     13    Promise.withResolvers();
     14 
     15  const LOCK_NAME = "Some lock";
     16 
     17  await locks.request(LOCK_NAME, async lock => {
     18    Assert.ok(lock, "Got the lock");
     19 
     20    let { held: heldLocks } = await locks.query();
     21    Assert.equal(heldLocks.length, 1, "Should only be 1 held lock");
     22    Assert.equal(heldLocks[0].name, LOCK_NAME, "Got the right lock name");
     23    Assert.equal(heldLocks[0].clientId, "", "Got an empty client ID");
     24 
     25    firstResolve();
     26  });
     27  await firstPromise;
     28 });