Update web-platform-tests to revision e45156b5e558c062a609356905c83a0258c516e3

This commit is contained in:
WPT Sync Bot 2019-05-02 21:47:51 -04:00
parent 9f6005be16
commit 5fcf52d946
199 changed files with 4430 additions and 530 deletions

View file

@ -17,6 +17,10 @@
// Presentation Availability Tests - begin
// ---------------------------------------
const catchNotSupported = err => {
assert_equals(err.name, 'NotSupportedError', 'getAvailability() rejects a Promise with a NotSupportedError exception, if the browser can find presentation displays only when starting a connection.')
};
promise_test(t => {
let availability;
@ -24,39 +28,27 @@
assert_true(request instanceof PresentationRequest, 'The request is an instance of PresentationRequest.');
const promise = request.getAvailability();
assert_equals(promise, request.getAvailability(), 'If the PresentationRequest object has an unsettled Promise, getAvailability returns that Promise.');
function catchNotSupported(err) {
assert_equals(err.name, 'NotSupportedError', 'getAvailability() rejects a Promise with a NotSupportedError exception, if the browser can find presentation displays only when starting a connection.')
}
assert_true(promise instanceof Promise, 'PresentationRequest.getAvailability() returns a Promise.');
const samePromise = request.getAvailability();
assert_true(samePromise instanceof Promise, 'PresentationRequest.getAvailabilty() returns a Promise.');
assert_equals(promise, samePromise, 'If the PresentationRequest object has an unsettled Promise, getAvailability returns that Promise.');
return promise.then(a => {
availability = a;
availability = a;
assert_true(availability instanceof PresentationAvailability, 'The promise is resolved with an instance of PresentationAvailability.');
assert_equals(typeof availability.value, 'boolean', 'The availability has an boolean value.');
assert_true(availability instanceof PresentationAvailability, 'The promise is resolved with an instance of PresentationAvailability.');
assert_equals(typeof availability.value, 'boolean', 'The availability has an boolean value.');
const request2 = new PresentationRequest('https://example.com');
return request2.getAvailability();
}).then(a => {
assert_not_equals(availability, a, 'A presentation availability object is newly created if the presentation request has a newly added presentation URLs.');
// The value of the presentation availability object is set to false, when the object is newly created.
const waitForChange = () => {
const eventWatcher = new EventWatcher(t, availability, 'change');
return eventWatcher.wait_for('change');
};
const newPromise = request.getAvailability();
assert_not_equals(promise, newPromise, 'If the Promise from a previous call to getAvailability has already been settled, getAvailability returns a new Promise.');
return (availability.value ? Promise.resolve() : waitForChange()).then(() => {
assert_true(availability.value, 'The availability value is true when any presentation display is available.');
const request2 = new PresentationRequest('https://example.com');
return request2.getAvailability();
}).then(a => {
assert_not_equals(availability, a, 'A presentation availability object is newly created if the presentation request has a newly added presentation URLs.');
const newPromise = request.getAvailability();
assert_not_equals(promise, newPromise, 'If the Promise from a previous call to getAvailability has already been settled, getAvailability returns a new Promise.');
return newPromise.then(newAvailability => {
assert_equals(availability, newAvailability, 'Promises from a PresentationRequest\'s getAvailability are resolved with the same PresentationAvailability object.');
}, catchNotSupported);
}, catchNotSupported);
return newPromise.then(newAvailability => {
assert_equals(availability, newAvailability, 'Promises from a PresentationRequest\'s getAvailability are resolved with the same PresentationAvailability object.');
}, catchNotSupported);
}, catchNotSupported);
});
</script>