Commit 85d36168 authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

wake lock: Make |type| optional in WakeLock.request().

Implement https://github.com/w3c/screen-wake-lock/pull/291, which makes
the |type| parameter optional and default to "screen" in
WakeLock.request().

Intent to Implement and Ship:
https://groups.google.com/a/chromium.org/g/blink-dev/c/HxWEyZz2nmI

ChromeStatus entry:
https://chromestatus.com/feature/5725750881681408

Fixed: 1133696
Change-Id: Id3eb6281bfedeaabfa3a7e22d530d0133b50411f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2445017
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/master@{#815113}
parent f0a4e684
...@@ -12,5 +12,5 @@ enum WakeLockType { ...@@ -12,5 +12,5 @@ enum WakeLockType {
SecureContext, SecureContext,
Exposed(DedicatedWorker SystemWakeLock, Window WakeLock) Exposed(DedicatedWorker SystemWakeLock, Window WakeLock)
] interface WakeLock { ] interface WakeLock {
[CallWith=ScriptState, RaisesException] Promise<WakeLockSentinel> request(WakeLockType type); [CallWith=ScriptState, RaisesException] Promise<WakeLockSentinel> request(optional WakeLockType type = "screen");
}; };
...@@ -3616,8 +3616,7 @@ crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-onrelease.https.html [ ...@@ -3616,8 +3616,7 @@ crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-onrelease.https.html [
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-request-denied.https.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-request-denied.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-supported-by-feature-policy.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-supported-by-feature-policy.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-type.https.any.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-type.https.window.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-type.https.any.worker.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelockpermissiondescriptor.https.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelockpermissiondescriptor.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/getScreens.tentative.https.window.html [ Failure ] crbug.com/1050754 external/wpt/screen_enumeration/getScreens.tentative.https.window.html [ Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/getScreens.values.https.html [ Failure ] crbug.com/1050754 external/wpt/screen_enumeration/getScreens.values.https.html [ Failure ]
......
...@@ -3639,7 +3639,7 @@ crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-enabled-on-self-origin- ...@@ -3639,7 +3639,7 @@ crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-enabled-on-self-origin-
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-onrelease.https.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-onrelease.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-request-denied.https.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-request-denied.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-type.https.any.worker.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-type.https.window.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelockpermissiondescriptor.https.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelockpermissiondescriptor.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/getScreens.tentative.https.window.html [ Failure ] crbug.com/1050754 external/wpt/screen_enumeration/getScreens.tentative.https.window.html [ Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/getScreens.values.https.html [ Failure ] crbug.com/1050754 external/wpt/screen_enumeration/getScreens.values.https.html [ Failure ]
......
...@@ -3881,8 +3881,7 @@ crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-onrelease.https.html [ ...@@ -3881,8 +3881,7 @@ crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-onrelease.https.html [
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-request-denied.https.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-request-denied.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-screen-type-on-worker.https.worker.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-supported-by-feature-policy.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-supported-by-feature-policy.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-type.https.any.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-type.https.window.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-type.https.any.worker.html [ Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelockpermissiondescriptor.https.html [ Failure ] crbug.com/1050754 external/wpt/screen-wake-lock/wakelockpermissiondescriptor.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/getScreens.tentative.https.window.html [ Failure ] crbug.com/1050754 external/wpt/screen_enumeration/getScreens.tentative.https.window.html [ Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/getScreens.values.https.html [ Failure ] crbug.com/1050754 external/wpt/screen_enumeration/getScreens.values.https.html [ Failure ]
......
...@@ -10,7 +10,7 @@ partial interface Navigator { ...@@ -10,7 +10,7 @@ partial interface Navigator {
[SecureContext, Exposed=(Window)] [SecureContext, Exposed=(Window)]
interface WakeLock { interface WakeLock {
Promise<WakeLockSentinel> request(WakeLockType type); Promise<WakeLockSentinel> request(optional WakeLockType type = "screen");
}; };
[SecureContext, Exposed=(Window)] [SecureContext, Exposed=(Window)]
......
//META: title=navigator.wakeLock.request() with invalid type
promise_test(async t => {
return promise_rejects_js(t, TypeError, navigator.wakeLock.request());
}, "'TypeError' is thrown when set an empty wake lock type");
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");
// 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', false);
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');
...@@ -12,7 +12,7 @@ partial interface WorkerNavigator { ...@@ -12,7 +12,7 @@ partial interface WorkerNavigator {
[SecureContext, Exposed=(DedicatedWorker, Window)] [SecureContext, Exposed=(DedicatedWorker, Window)]
interface WakeLock { interface WakeLock {
Promise<WakeLockSentinel> request(WakeLockType type); Promise<WakeLockSentinel> request(optional WakeLockType type = "screen");
}; };
[SecureContext, Exposed=(DedicatedWorker, Window)] [SecureContext, Exposed=(DedicatedWorker, Window)]
...@@ -20,4 +20,4 @@ interface WakeLockSentinel : EventTarget { ...@@ -20,4 +20,4 @@ interface WakeLockSentinel : EventTarget {
readonly attribute WakeLockType type; readonly attribute WakeLockType type;
Promise<void> release(); Promise<void> release();
attribute EventHandler onrelease; attribute EventHandler onrelease;
}; };
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment