mirror of
https://github.com/servo/servo.git
synced 2025-07-10 08:53:41 +01:00
31 lines
1.2 KiB
HTML
31 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset="utf-8">
|
|
<title>screen wake lock will not be actived in hidden document</title>
|
|
<link rel="help" href="https://w3c.github.io/wake-lock/#dfn-requesting-the-wake-lock">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script>
|
|
|
|
promise_test(async t => {
|
|
const wakeLock = new WakeLock("screen");
|
|
|
|
const controller = new AbortController();
|
|
const signal = controller.signal;
|
|
|
|
await wakeLock.request({ signal });
|
|
assert_true(wakeLock.active, "the active is true when wake lock is acquired");
|
|
const eventWatcher = new EventWatcher(t, document, "visibilitychange");
|
|
const win = window.open("about:blank", "_blank");
|
|
|
|
await eventWatcher.wait_for("visibilitychange");
|
|
assert_true(document.hidden, "document is hidden when new window is opened");
|
|
assert_false(wakeLock.active, "the active is false when document is hidden");
|
|
win.close();
|
|
|
|
await eventWatcher.wait_for("visibilitychange");
|
|
assert_false(document.hidden, "document is visiable when new window is closed");
|
|
assert_true(wakeLock.active, "the active is true when document regains visibility");
|
|
controller.abort();
|
|
}, "Test that screen wake lock will not be actived in hidden document");
|
|
|
|
</script>
|