mirror of
https://github.com/servo/servo.git
synced 2025-08-17 03:15:34 +01:00
Update web-platform-tests to revision ddfc95cf0493ae147a4f6a4d7be8eff1a0c23098
This commit is contained in:
parent
1f6a864ab5
commit
7e6290451f
832 changed files with 16026 additions and 2649 deletions
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
const test_desc = 'disconnect() called before FUNCTION_NAME. ' +
|
||||
'Reject with NetworkError.';
|
||||
const expected = new DOMException(
|
||||
'GATT Server is disconnected. Cannot retrieve services. (Re)connect ' +
|
||||
'first with `device.gatt.connect`.',
|
||||
'NetworkError');
|
||||
let device;
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice({
|
||||
filters: [{services: ['health_thermometer']}],
|
||||
optionalServices: ['generic_access']
|
||||
})
|
||||
.then(_ => ({device} = _))
|
||||
.then(() => device.gatt.disconnect())
|
||||
.then(() => assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('health_thermometer')|
|
||||
getPrimaryServices()|
|
||||
getPrimaryServices('health_thermometer')[UUID]]),
|
||||
expected)),
|
||||
test_desc);
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
const test_desc = 'disconnect() called during a FUNCTION_NAME ' +
|
||||
'call that fails. Reject with NetworkError.';
|
||||
const expected = new DOMException(
|
||||
'GATT Server is disconnected. Cannot retrieve services. (Re)connect ' +
|
||||
'first with `device.gatt.connect`.', 'NetworkError');
|
||||
let device;
|
||||
|
||||
bluetooth_test(() => getEmptyHealthThermometerDevice()
|
||||
.then(_ => ({device} = _))
|
||||
.then(() => {
|
||||
let promise = assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('health_thermometer')|
|
||||
getPrimaryServices()|
|
||||
getPrimaryServices('health_thermometer')[UUID]
|
||||
]),
|
||||
expected)
|
||||
device.gatt.disconnect();
|
||||
return promise;
|
||||
}),
|
||||
test_desc);
|
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
const test_desc = 'disconnect() called during a FUNCTION_NAME call that ' +
|
||||
'succeeds. Reject with NetworkError.';
|
||||
const expected = new DOMException(
|
||||
'GATT Server is disconnected. Cannot retrieve services. (Re)connect ' +
|
||||
'first with `device.gatt.connect`.',
|
||||
'NetworkError');
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice({
|
||||
filters: [{services: ['health_thermometer']}],
|
||||
optionalServices: ['generic_access']
|
||||
})
|
||||
.then(({device}) => {
|
||||
let promise = assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('health_thermometer')|
|
||||
getPrimaryServices()|
|
||||
getPrimaryServices('health_thermometer')[UUID]
|
||||
]),
|
||||
expected);
|
||||
device.gatt.disconnect();
|
||||
return promise;
|
||||
}), test_desc);
|
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
const test_desc = 'Calls on services after we disconnect and connect again. '+
|
||||
'Should reject with InvalidStateError.';
|
||||
let device, services;
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice({
|
||||
filters: [{services: ['health_thermometer']}]
|
||||
})
|
||||
.then(_ => ({device} = _))
|
||||
.then(() => device.gatt.CALLS([
|
||||
getPrimaryService('health_thermometer')|
|
||||
getPrimaryServices()|
|
||||
getPrimaryServices('health_thermometer')[UUID]]))
|
||||
// Convert to array if necessary.
|
||||
.then(s => services = [].concat(s))
|
||||
.then(() => device.gatt.disconnect())
|
||||
.then(() => device.gatt.connect())
|
||||
.then(() => {
|
||||
let promises = Promise.resolve();
|
||||
for (let service of services) {
|
||||
let error = new DOMException(
|
||||
`Service with UUID ${service.uuid} is no longer valid. Remember ` +
|
||||
`to retrieve the service again after reconnecting.`,
|
||||
'InvalidStateError');
|
||||
promises = promises.then(() =>
|
||||
assert_promise_rejects_with_message(
|
||||
service.getCharacteristic('measurement_interval'),
|
||||
error));
|
||||
promises = promises.then(() =>
|
||||
assert_promise_rejects_with_message(
|
||||
service.getCharacteristics(),
|
||||
error));
|
||||
promises = promises.then(() =>
|
||||
assert_promise_rejects_with_message(
|
||||
service.getCharacteristics('measurement_interval'),
|
||||
error));
|
||||
}
|
||||
return promises;
|
||||
}), test_desc);
|
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
const test_desc = 'FUNCTION_NAME called before connecting. Reject with ' +
|
||||
'NetworkError.';
|
||||
const expected = new DOMException(
|
||||
'GATT Server is disconnected. Cannot retrieve services. (Re)connect ' +
|
||||
'first with `device.gatt.connect`.',
|
||||
'NetworkError');
|
||||
|
||||
bluetooth_test(() => getDiscoveredHealthThermometerDevice({
|
||||
filters: [{services: ['health_thermometer']}],
|
||||
optionalServices: ['generic_access']
|
||||
})
|
||||
.then(({device}) => assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('health_thermometer')|
|
||||
getPrimaryServices()|
|
||||
getPrimaryServices('health_thermometer')[UUID]
|
||||
]),
|
||||
expected)),
|
||||
test_desc);
|
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
const test_desc = 'Request for absent service without permission. Should ' +
|
||||
'Reject with SecurityError even if services have been discovered already.';
|
||||
const expected = new DOMException(
|
||||
'Origin is not allowed to access the service. Tip: Add the service ' +
|
||||
'UUID to \'optionalServices\' in requestDevice() options. ' +
|
||||
'https://goo.gl/HxfxSQ',
|
||||
'SecurityError');
|
||||
let device;
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDeviceWithServicesDiscovered({
|
||||
filters: [{services: ['health_thermometer']}]
|
||||
})
|
||||
.then(_ => ({device} = _))
|
||||
.then(() => Promise.all([
|
||||
assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService(glucose.alias)|
|
||||
getPrimaryServices(glucose.alias)[UUID]
|
||||
]), expected),
|
||||
assert_promise_rejects_with_message(
|
||||
device.gatt.FUNCTION_NAME(glucose.name), expected),
|
||||
assert_promise_rejects_with_message(
|
||||
device.gatt.FUNCTION_NAME(glucose.uuid), expected)])),
|
||||
test_desc);
|
|
@ -0,0 +1,16 @@
|
|||
'use strict';
|
||||
const test_desc = 'Request for absent service. Must reject with ' +
|
||||
'NotFoundError even when the services have previously been discovered.';
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDeviceWithServicesDiscovered({
|
||||
filters: [{services: ['health_thermometer']}],
|
||||
optionalServices: ['glucose']})
|
||||
.then(({device}) => assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('glucose')|
|
||||
getPrimaryServices('glucose')[UUID]
|
||||
]),
|
||||
new DOMException(
|
||||
`No Services matching UUID ${glucose.uuid} found in Device.`,
|
||||
'NotFoundError'))),
|
||||
test_desc);
|
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
const test_desc = 'Garbage Collection ran during a FUNCTION_NAME ' +
|
||||
'call that failed. Should not crash.'
|
||||
const expected = new DOMException(
|
||||
'GATT Server is disconnected. Cannot retrieve services. (Re)connect first ' +
|
||||
'with `device.gatt.connect`.',
|
||||
'NetworkError');
|
||||
let promise;
|
||||
|
||||
bluetooth_test(() => getEmptyHealthThermometerDevice()
|
||||
.then(({device}) => {
|
||||
promise = assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('health_thermometer')|
|
||||
getPrimaryServices()|
|
||||
getPrimaryServices('health_thermometer')[UUID]
|
||||
]),
|
||||
expected);
|
||||
// Disconnect called to clear attributeInstanceMap and allow the
|
||||
// object to get garbage collected.
|
||||
device.gatt.disconnect();
|
||||
return runGarbageCollection();
|
||||
})
|
||||
.then(() => promise),
|
||||
test_desc);
|
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
const test_desc = 'Garbage Collection ran during a FUNCTION_NAME call that ' +
|
||||
'succeeds. Should not crash.';
|
||||
const expected = new DOMException(
|
||||
'GATT Server is disconnected. Cannot retrieve services. ' +
|
||||
'(Re)connect first with `device.gatt.connect`.',
|
||||
'NetworkError');
|
||||
let promise;
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice({
|
||||
filters: [{services: ['health_thermometer']}]
|
||||
})
|
||||
.then(({device}) => {
|
||||
promise = assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('health_thermometer') |
|
||||
getPrimaryServices() |
|
||||
getPrimaryServices('health_thermometer')[UUID]]),
|
||||
expected);
|
||||
device.gatt.disconnect();
|
||||
return runGarbageCollection();
|
||||
})
|
||||
.then(() => promise),
|
||||
test_desc);
|
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
const test_desc = 'Calls to FUNCTION_NAME after a disconnection should return ' +
|
||||
'a different object.';
|
||||
let device, services_first_connection, services_second_connection;
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice({
|
||||
filters: [{services: ['health_thermometer']}],
|
||||
optionalServices: ['generic_access']
|
||||
})
|
||||
.then(_ => ({device} = _))
|
||||
.then(() => device.gatt.CALLS([
|
||||
getPrimaryService('health_thermometer')|
|
||||
getPrimaryServices()|
|
||||
getPrimaryServices('health_thermometer')[UUID]]))
|
||||
.then(services => services_first_connection = services)
|
||||
.then(() => device.gatt.disconnect())
|
||||
.then(() => device.gatt.connect())
|
||||
.then(() => device.gatt.PREVIOUS_CALL)
|
||||
.then(services => services_second_connection = services)
|
||||
.then(() => {
|
||||
// Convert to arrays if necessary.
|
||||
services_first_connection = [].concat(services_first_connection);
|
||||
services_second_connection = [].concat(services_second_connection);
|
||||
|
||||
assert_equals(services_first_connection.length,
|
||||
services_second_connection.length);
|
||||
|
||||
let first_connection_set = new Set(services_first_connection);
|
||||
let second_connection_set = new Set(services_second_connection);
|
||||
|
||||
// The two sets should be disjoint.
|
||||
let common_services = services_first_connection.filter(
|
||||
val => second_connection_set.has(val));
|
||||
assert_equals(common_services.length, 0);
|
||||
}), test_desc);
|
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
const test_desc = 'Calls to FUNCTION_NAME should return the same object.';
|
||||
let device;
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice({
|
||||
filters: [{services: ['health_thermometer']}],
|
||||
optionalServices: ['generic_access']})
|
||||
.then(({device}) => Promise.all([
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('health_thermometer')|
|
||||
getPrimaryServices()|
|
||||
getPrimaryServices('health_thermometer')[UUID]]),
|
||||
device.gatt.PREVIOUS_CALL]))
|
||||
.then(([services_first_call, services_second_call]) => {
|
||||
// Convert to arrays if necessary.
|
||||
services_first_call = [].concat(services_first_call);
|
||||
services_second_call = [].concat(services_second_call);
|
||||
|
||||
assert_equals(services_first_call.length, services_second_call.length);
|
||||
|
||||
let first_call_set = new Set(services_first_call);
|
||||
assert_equals(services_first_call.length, first_call_set.size);
|
||||
let second_call_set = new Set(services_second_call);
|
||||
assert_equals(services_second_call.length, second_call_set.size);
|
||||
|
||||
services_first_call.forEach(service => {
|
||||
assert_true(second_call_set.has(service))
|
||||
});
|
||||
|
||||
services_second_call.forEach(service => {
|
||||
assert_true(first_call_set.has(service));
|
||||
});
|
||||
}), test_desc);
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
const test_desc = 'Wrong Service name. Reject with TypeError.';
|
||||
const expected = new DOMException(
|
||||
"Failed to execute 'FUNCTION_NAME' on " +
|
||||
"'BluetoothRemoteGATTServer': Invalid Service name: " +
|
||||
"'wrong_name'. It must be a valid UUID alias (e.g. 0x1234), " +
|
||||
"UUID (lowercase hex characters e.g. " +
|
||||
"'00001234-0000-1000-8000-00805f9b34fb'), " +
|
||||
"or recognized standard name from " +
|
||||
"https://www.bluetooth.com/specifications/gatt/services" +
|
||||
" e.g. 'alert_notification'.",
|
||||
'TypeError');
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice()
|
||||
.then(({device}) => assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('wrong_name')|
|
||||
getPrimaryServices('wrong_name')
|
||||
]),
|
||||
expected,
|
||||
'Wrong Service name passed.')),
|
||||
test_desc);
|
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
const test_desc = 'Request for absent service without permission. ' +
|
||||
'Reject with SecurityError.';
|
||||
const expected = new DOMException(
|
||||
'Origin is not allowed to access the service. Tip: Add the service UUID ' +
|
||||
'to \'optionalServices\' in requestDevice() options. ' +
|
||||
'https://goo.gl/HxfxSQ',
|
||||
'SecurityError');
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice({
|
||||
filters: [{services: ['health_thermometer']}]
|
||||
})
|
||||
.then(({device}) => Promise.all([
|
||||
assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService(glucose.alias)|
|
||||
getPrimaryServices(glucose.alias)[UUID]
|
||||
]), expected),
|
||||
assert_promise_rejects_with_message(
|
||||
device.gatt.FUNCTION_NAME(glucose.name), expected),
|
||||
assert_promise_rejects_with_message(
|
||||
device.gatt.FUNCTION_NAME(glucose.uuid), expected)])),
|
||||
test_desc);
|
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
const test_desc = 'Request for present service without permission to access ' +
|
||||
'any service. Reject with SecurityError.';
|
||||
const expected = new DOMException(
|
||||
'Origin is not allowed to access any service. Tip: Add the service ' +
|
||||
'UUID to \'optionalServices\' in requestDevice() options. ' +
|
||||
'https://goo.gl/HxfxSQ',
|
||||
'SecurityError');
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice({acceptAllDevices: true})
|
||||
.then(({device}) => assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('heart_rate')|
|
||||
getPrimaryServices()|
|
||||
getPrimaryServices('heart_rate')[UUID]]),
|
||||
expected)),
|
||||
test_desc);
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
const test_desc = 'Request for present service without permission. ' +
|
||||
'Reject with SecurityError.';
|
||||
const expected = new DOMException(
|
||||
'Origin is not allowed to access the service. Tip: Add the service UUID ' +
|
||||
'to \'optionalServices\' in requestDevice() options. https://goo.gl/HxfxSQ',
|
||||
'SecurityError');
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice({
|
||||
filters: [{services: ['health_thermometer']}]
|
||||
})
|
||||
.then(({device}) => Promise.all([
|
||||
assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService(generic_access.alias)|
|
||||
getPrimaryServices(generic_access.alias)[UUID]
|
||||
]), expected),
|
||||
assert_promise_rejects_with_message(
|
||||
device.gatt.FUNCTION_NAME(generic_access.name), expected),
|
||||
assert_promise_rejects_with_message(
|
||||
device.gatt.FUNCTION_NAME(generic_access.uuid), expected)])),
|
||||
test_desc);
|
|
@ -0,0 +1,16 @@
|
|||
'use strict';
|
||||
const test_desc = 'Request for absent service. Reject with NotFoundError.';
|
||||
|
||||
bluetooth_test(() => getHealthThermometerDevice({
|
||||
filters: [{services: ['health_thermometer']}],
|
||||
optionalServices: ['glucose']
|
||||
})
|
||||
.then(({device}) => assert_promise_rejects_with_message(
|
||||
device.gatt.CALLS([
|
||||
getPrimaryService('glucose')|
|
||||
getPrimaryServices('glucose')[UUID]
|
||||
]),
|
||||
new DOMException(
|
||||
`No Services matching UUID ${glucose.uuid} found in Device.`,
|
||||
'NotFoundError'))),
|
||||
test_desc);
|
Loading…
Add table
Add a link
Reference in a new issue