summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden-manual.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden-manual.https.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden-manual.https.html')
-rw-r--r--testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden-manual.https.html30
1 files changed, 30 insertions, 0 deletions
diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden-manual.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden-manual.https.html
new file mode 100644
index 0000000000..05368bdfb8
--- /dev/null
+++ b/testing/web-platform/tests/screen-wake-lock/wakelock-document-hidden-manual.https.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name="timeout" content="long">
+<title>Screen wake locks respect page visibility changes</title>
+<link rel="help" href="https://w3c.github.io/screen-wake-lock/#handling-document-loss-of-visibility">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+
+promise_test(async t => {
+ const screenWakeLock = await navigator.wakeLock.request('screen');
+ assert_false(screenWakeLock.released, "The released attribute is initially false")
+ const screenWakeLockReleased =
+ new EventWatcher(t, screenWakeLock, "release").wait_for("release");
+
+ const eventWatcher = new EventWatcher(t, document, "visibilitychange");
+ await eventWatcher.wait_for("visibilitychange");
+ assert_true(document.hidden, "document is hidden after the visibilitychange event");
+ await screenWakeLockReleased;
+ assert_true(screenWakeLock.released, "The released attribute is true after the lock is released");
+ await promise_rejects_dom(t, "NotAllowedError", navigator.wakeLock.request('screen'),
+ "new screen locks are not allowed when the page is not visible");
+
+ await eventWatcher.wait_for("visibilitychange");
+ assert_false(document.hidden, "document is no longer hidden after the visibilitychange event");
+}, "Test screen locks respect page visibility changes");
+
+</script>
+
+<p>Switch the page to the background, then switch back to it.</p>