blob: 8d98db7c14a3c924b1199584059b4c35c0ef3c51 [file] [log] [blame]
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<body>
<script>
promise_test(async (t) => {
assert_false(navigator.userActivation.isActive, "No user activation yet.");
await promise_rejects_dom(
t,
"NotAllowedError",
navigator.wakeLock.request("screen"),
"Must reject as there is no user activation"
);
await test_driver.bless("screen wake lock");
const lockPromises = [
navigator.wakeLock.request(),
navigator.wakeLock.request(),
navigator.wakeLock.request(),
];
assert_true(navigator.userActivation.isActive, "Transient activation must not be consumed.");
const locks = await Promise.all(lockPromises);
await Promise.all(locks.map((lock) => lock.release()));
}, "Requesting a screen wake lock requires transient activation, but does not consume it");
</script>
</body>
</html>