mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update web-platform-tests to revision a589fd30bc64bb4d40e1d6854e07accca69b8472
This commit is contained in:
parent
81ab255b70
commit
fd4e600639
57 changed files with 1735 additions and 208 deletions
|
@ -0,0 +1,69 @@
|
|||
// META: title=Idle Detection API: Basics
|
||||
|
||||
'use strict';
|
||||
|
||||
promise_test(async t => {
|
||||
let promise = navigator.idle.query();
|
||||
assert_equals(promise.constructor, Promise,
|
||||
'query() returns a promise');
|
||||
|
||||
let status = await promise;
|
||||
assert_true(status instanceof IdleStatus,
|
||||
'query() promise resolves to an IdleStatus');
|
||||
|
||||
assert_true(['active', 'idle', 'locked'].includes(status.state),
|
||||
'status has a valid state');
|
||||
}, 'query() basics');
|
||||
|
||||
promise_test(async t => {
|
||||
let used = false;
|
||||
|
||||
await navigator.idle.query({
|
||||
get threshold() {
|
||||
used = true;
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
assert_true(used, 'query() options "threshold" member was used');
|
||||
}, 'query() uses threshold property');
|
||||
|
||||
promise_test(async t => {
|
||||
return promise_rejects(
|
||||
t,
|
||||
new TypeError,
|
||||
navigator.idle.query({threshold: 0}),
|
||||
'Threshold of 0 should reject');
|
||||
}, 'query() throws with invalid threshold (0)');
|
||||
|
||||
promise_test(async t => {
|
||||
return promise_rejects(
|
||||
t,
|
||||
new TypeError,
|
||||
navigator.idle.query({threshold: null}),
|
||||
'Threshold of null should reject');
|
||||
}, 'query() throws with invalid threshold (null)');
|
||||
|
||||
promise_test(async t => {
|
||||
return promise_rejects(
|
||||
t,
|
||||
new TypeError,
|
||||
navigator.idle.query({threshold: -1}),
|
||||
'Threshold of negative numbers should reject');
|
||||
}, 'query() throws with invalid threshold (-1)');
|
||||
|
||||
promise_test(async t => {
|
||||
return promise_rejects(
|
||||
t,
|
||||
new TypeError,
|
||||
navigator.idle.query({threshold: NaN}),
|
||||
'Threshold of NaN should reject');
|
||||
}, 'query() throws with invalid threshold (NaN)');
|
||||
|
||||
promise_test(async t => {
|
||||
return navigator.idle.query();
|
||||
}, 'query() uses a default value for the threshold when none is passed');
|
||||
|
||||
promise_test(async t => {
|
||||
return navigator.idle.query({threshold: undefined});
|
||||
}, 'query() uses a default value for the threshold');
|
Loading…
Add table
Add a link
Reference in a new issue