tor-browser

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

browser_wakelock.js (875B)


      1 /**
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/publicdomain/zero/1.0/
      4 */
      5 
      6 "use strict";
      7 
      8 add_task(async () => {
      9  info("creating test window");
     10  let win = await BrowserTestUtils.openNewBrowserWindow();
     11 
     12  const pm = Cc["@mozilla.org/power/powermanagerservice;1"].getService(
     13    Ci.nsIPowerManagerService
     14  );
     15 
     16  is(
     17    pm.getWakeLockState("screen"),
     18    "unlocked",
     19    "Wakelock should be unlocked state"
     20  );
     21 
     22  info("aquiring wakelock");
     23  const wakelock = pm.newWakeLock("screen", win);
     24  isnot(
     25    pm.getWakeLockState("screen"),
     26    "unlocked",
     27    "Wakelock shouldn't be unlocked state"
     28  );
     29 
     30  info("releasing wakelock");
     31  wakelock.unlock();
     32  is(
     33    pm.getWakeLockState("screen"),
     34    "unlocked",
     35    "Wakelock should be unlocked state"
     36  );
     37 
     38  info("closing test window");
     39  await BrowserTestUtils.closeWindow(win);
     40 });