mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision b7a8b84debb42268ea95a45bdad8f727d1facdf7
This commit is contained in:
parent
ba929208e4
commit
953dbda9a6
215 changed files with 6409 additions and 1644 deletions
|
@ -3,70 +3,76 @@
|
|||
'use strict';
|
||||
|
||||
promise_test(async t => {
|
||||
let promise = navigator.idle.query();
|
||||
assert_equals(promise.constructor, Promise,
|
||||
'query() returns a promise');
|
||||
let status = new IdleDetector();
|
||||
|
||||
let status = await promise;
|
||||
assert_true(status instanceof IdleStatus,
|
||||
'query() promise resolves to an IdleStatus');
|
||||
let watcher = new EventWatcher(t, status, ["change"]);
|
||||
|
||||
await status.start();
|
||||
|
||||
await watcher.wait_for("change");
|
||||
|
||||
assert_true(['active', 'idle'].includes(status.state.user),
|
||||
'status has a valid user state');
|
||||
assert_true(['locked', 'unlocked'].includes(status.state.screen),
|
||||
'status has a valid screen state');
|
||||
|
||||
}, 'query() basics');
|
||||
}, 'start() basics');
|
||||
|
||||
promise_test(async t => {
|
||||
let used = false;
|
||||
|
||||
await navigator.idle.query({
|
||||
new IdleDetector({
|
||||
get threshold() {
|
||||
used = true;
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
assert_true(used, 'query() options "threshold" member was used');
|
||||
}, 'query() uses threshold property');
|
||||
assert_true(used, 'constructor options "threshold" member was used');
|
||||
}, 'constructor 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)');
|
||||
try {
|
||||
new IdleDetector({threshold: 0});
|
||||
assert_unreached('Threshold of 0 should reject');
|
||||
} catch (error) {
|
||||
assert_equals(error.name, 'TypeError');
|
||||
}
|
||||
}, 'constructor 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)');
|
||||
try {
|
||||
new IdleDetector({threshold: null});
|
||||
assert_unreached('Threshold of null should reject');
|
||||
} catch (error) {
|
||||
assert_equals(error.name, 'TypeError');
|
||||
}
|
||||
}, 'constructor 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)');
|
||||
try {
|
||||
new IdleDetector({threshold: -1});
|
||||
assert_unreached('Threshold of negative numbers should reject');
|
||||
} catch (error) {
|
||||
assert_equals(error.name, 'TypeError');
|
||||
}
|
||||
}, 'constructor 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)');
|
||||
try {
|
||||
new IdleDetector({threshold: NaN});
|
||||
assert_unreached('Threshold of NaN should reject');
|
||||
} catch (error) {
|
||||
assert_equals(error.name, 'TypeError');
|
||||
}
|
||||
}, 'constructor 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');
|
||||
new IdleDetector();
|
||||
}, 'constructor 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');
|
||||
new IdleDetector({threshold: undefined});
|
||||
}, 'constructor uses a default value for the threshold');
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue