summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/screen-wake-lock/wakelock-onrelease.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-onrelease.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-onrelease.https.html')
-rw-r--r--testing/web-platform/tests/screen-wake-lock/wakelock-onrelease.https.html39
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-onrelease.https.html b/testing/web-platform/tests/screen-wake-lock/wakelock-onrelease.https.html
new file mode 100644
index 0000000000..fb071b3763
--- /dev/null
+++ b/testing/web-platform/tests/screen-wake-lock/wakelock-onrelease.https.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<link rel="help" href="https://w3c.github.io/screen-wake-lock/#the-onrelease-attribute">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script>
+promise_test(async t => {
+ await test_driver.set_permission({name: 'screen-wake-lock'}, 'granted');
+
+ const lock = await navigator.wakeLock.request("screen");
+ return new Promise(resolve => {
+ lock.onrelease = resolve;
+ lock.release();
+ }).then(ev => {
+ assert_class_string(ev, "Event", "release() must fire an Event object");
+ assert_equals(ev.target, lock, "The event's target must be the lock that was acquired");
+ assert_true(ev.isTrusted);
+ assert_false(ev.bubbles);
+ assert_false(ev.cancelable);
+ });
+}, "Test onreleased event's basic properties");
+
+promise_test(async t => {
+ await test_driver.set_permission({ name: 'screen-wake-lock' }, 'granted');
+
+ const lock = await navigator.wakeLock.request("screen");
+
+ let releaseFired = false;
+ lock.onrelease = t.step_func(() => {
+ releaseFired = true;
+ });
+
+ const releasePromise = lock.release();
+ assert_true(releaseFired, "The 'release' event fires immediately after release() is called");
+
+ return releasePromise;
+}, "Ensure onreleased is called before WakeLockSentinel.release() resolves");
+</script>