Update web-platform-tests to revision b7a8b84debb42268ea95a45bdad8f727d1facdf7

This commit is contained in:
WPT Sync Bot 2019-03-21 21:40:20 -04:00
parent ba929208e4
commit 953dbda9a6
215 changed files with 6409 additions and 1644 deletions

View file

@ -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');