summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/permissions-policy/resources/permissions-policy-screen-wakelock.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/permissions-policy/resources/permissions-policy-screen-wakelock.html')
-rw-r--r--testing/web-platform/tests/permissions-policy/resources/permissions-policy-screen-wakelock.html22
1 files changed, 22 insertions, 0 deletions
diff --git a/testing/web-platform/tests/permissions-policy/resources/permissions-policy-screen-wakelock.html b/testing/web-platform/tests/permissions-policy/resources/permissions-policy-screen-wakelock.html
new file mode 100644
index 0000000000..5c2562946b
--- /dev/null
+++ b/testing/web-platform/tests/permissions-policy/resources/permissions-policy-screen-wakelock.html
@@ -0,0 +1,22 @@
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script>
+"use strict";
+
+Promise.resolve().then(async () => {
+ test_driver.set_test_context(window.parent);
+ await test_driver.set_permission({ name: 'screen-wake-lock' }, 'granted');
+
+ try {
+ const wakeLock = await navigator.wakeLock.request("screen");
+ window.parent.postMessage({ type: 'availability-result', enabled: true }, "*");
+ await wakeLock.release();
+ } catch (e) {
+ if (e instanceof DOMException && e.name === "NotAllowedError") {
+ window.parent.postMessage({ type: 'availability-result', enabled: false }, "*");
+ } else {
+ throw e;
+ }
+ }
+});
+</script>