summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/screen-wake-lock/wakelock-type.https.window.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/screen-wake-lock/wakelock-type.https.window.js')
-rw-r--r--testing/web-platform/tests/screen-wake-lock/wakelock-type.https.window.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/testing/web-platform/tests/screen-wake-lock/wakelock-type.https.window.js b/testing/web-platform/tests/screen-wake-lock/wakelock-type.https.window.js
new file mode 100644
index 0000000000..5008064684
--- /dev/null
+++ b/testing/web-platform/tests/screen-wake-lock/wakelock-type.https.window.js
@@ -0,0 +1,21 @@
+// META: script=/resources/testdriver.js
+// META: script=/resources/testdriver-vendor.js
+
+promise_test(async t => {
+ await test_driver.set_permission(
+ {name: 'screen-wake-lock'}, 'granted');
+
+ const lock = await navigator.wakeLock.request();
+ t.add_cleanup(() => {
+ lock.release();
+ });
+ assert_equals(lock.type, 'screen');
+}, '\'type\' parameter in WakeLock.request() defaults to \'screen\'');
+
+promise_test(t => {
+ const invalidTypes = ['invalid', null, 123, {}, '', true];
+ return Promise.all(invalidTypes.map(invalidType => {
+ return promise_rejects_js(
+ t, TypeError, navigator.wakeLock.request(invalidType));
+ }));
+}, '\'TypeError\' is thrown when set an invalid wake lock type');