Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: dom/power/tests/mochitest.toml
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test Screen Wake Lock responds to dynamic pref changes</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/* globals SpecialPowers */
'use strict';
function spinEventLoop() {
return new Promise(resolve => {
setTimeout(resolve, 0);
});
}
add_task(async function my_test() {
const lock = await navigator.wakeLock.request("screen");
await SpecialPowers.pushPrefEnv({
set: [["dom.screenwakelock.enabled", false]],
});
await spinEventLoop();
ok(lock.released, "Lock was released once pref was deactivated");
await SpecialPowers.popPrefEnv();
});
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</html>