mirror of
https://github.com/servo/servo.git
synced 2025-08-18 11:55:39 +01:00
Update web-platform-tests to revision ac3d096a5972dea5ecca1c43e324086895db7c6f
This commit is contained in:
parent
1c74a80e28
commit
db54f176d0
47 changed files with 860 additions and 246 deletions
|
@ -1,12 +1,25 @@
|
|||
<script>
|
||||
"use strict";
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
try {
|
||||
const wakeLock = new WakeLock("screen");
|
||||
window.parent.postMessage({ enabled: true }, "*");
|
||||
} catch (e) {
|
||||
window.parent.postMessage({ enabled: false }, "*");
|
||||
}
|
||||
Promise.resolve().then(async () => {
|
||||
// On success, WakeLock.request() returns a promise that never resolves. To
|
||||
// prevent a timeout, abort it with an AbortController and use the different
|
||||
// DOMExceptions we get to determine if this worked or not.
|
||||
const controller = new AbortController();
|
||||
const wakeLock = WakeLock.request("screen", { signal: controller.signal });
|
||||
wakeLock.catch(e => {
|
||||
if (e.name == "AbortError") {
|
||||
// We stopped due to the call to AbortController.abort(), so we did manage
|
||||
// to get the lock.
|
||||
window.parent.postMessage({ enabled: true }, "*");
|
||||
} else if (e.name == "NotAllowedError") {
|
||||
// This means requesting the lock failed.
|
||||
window.parent.postMessage({ enabled: false }, "*");
|
||||
} else {
|
||||
// We should not really hit this branch.
|
||||
window.parent.postMessage({ enabled: false }, "*");
|
||||
}
|
||||
});
|
||||
controller.abort();
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue