servo/tests/wpt/web-platform-tests/wake-lock/wakelock-cancel-twice.https.html

20 lines
819 B
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<title>no exception is thrown when invoking cancel() twice</title>
<link rel="help" href="https://w3c.github.io/wake-lock/#dom-wakelockrequest-cancel">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(async t => {
const wakeLock = await navigator.getWakeLock("screen");
const request = wakeLock.createRequest();
assert_true(wakeLock.active, "the activate is true when wake lock is acquired");
request.cancel();
assert_false(wakeLock.active, "the activate is false when wake lock is released");
//If the cancel() method has already been invoked on this object,
//abort these steps, no error fired
request.cancel();
}, "no exception is thrown when invoking cancel() twice");
</script>