| Index: third_party/WebKit/LayoutTests/bluetooth/script-tests/service-disconnect-invalidates-objects.js
|
| diff --git a/third_party/WebKit/LayoutTests/bluetooth/script-tests/service-disconnect-invalidates-objects.js b/third_party/WebKit/LayoutTests/bluetooth/script-tests/service-disconnect-invalidates-objects.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..98454d4a20e43ca954e7fc171528014ec2ba472a
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/bluetooth/script-tests/service-disconnect-invalidates-objects.js
|
| @@ -0,0 +1,45 @@
|
| +'use strict';
|
| +promise_test(() => {
|
| + let promise;
|
| + return setBluetoothFakeAdapter('TwoHeartRateServicesAdapter')
|
| + .then(() => requestDeviceWithKeyDown({
|
| + filters: [{services: ['heart_rate']}]}))
|
| + .then(device => device.gatt.connect())
|
| + .then(gattServer => {
|
| + return gattServer
|
| + .CALLS([
|
| + getPrimaryService('heart_rate')|
|
| + getPrimaryServices()|
|
| + getPrimaryServices('heart_rate')[UUID]])
|
| + // Convert to array if necessary.
|
| + .then(s => {
|
| + let services = [].concat(s);
|
| + gattServer.disconnect();
|
| + return gattServer.connect()
|
| + .then(() => services);
|
| + });
|
| + })
|
| + .then(services => {
|
| + let promises = Promise.resolve();
|
| + for (let service of services) {
|
| + let error = new DOMException(
|
| + 'Service is no longer valid. Remember to retrieve the service ' +
|
| + 'again after reconnecting.',
|
| + 'InvalidStateError');
|
| + promises = promises.then(() =>
|
| + assert_promise_rejects_with_message(
|
| + service.getCharacteristic('body_sensor_location'),
|
| + error));
|
| + promises = promises.then(() =>
|
| + assert_promise_rejects_with_message(
|
| + service.getCharacteristics(),
|
| + error));
|
| + promises = promises.then(() =>
|
| + assert_promise_rejects_with_message(
|
| + service.getCharacteristics('body_sensor_location'),
|
| + error));
|
| + }
|
| + return promises;
|
| + });
|
| +}, 'Calls on services after we disconnect and connect again. '+
|
| + 'Should reject with InvalidStateError.');
|
|
|