| Index: third_party/WebKit/LayoutTests/bluetooth/script-tests/characteristic-device-disconnects-invalidates-objects.js
|
| diff --git a/third_party/WebKit/LayoutTests/bluetooth/getPrimaryServices/gen-service-device-disconnects-invalidates-objects.html b/third_party/WebKit/LayoutTests/bluetooth/script-tests/characteristic-device-disconnects-invalidates-objects.js
|
| similarity index 52%
|
| copy from third_party/WebKit/LayoutTests/bluetooth/getPrimaryServices/gen-service-device-disconnects-invalidates-objects.html
|
| copy to third_party/WebKit/LayoutTests/bluetooth/script-tests/characteristic-device-disconnects-invalidates-objects.js
|
| index 542b18cefd1a23ec7ed25049809dbd52a4e4698c..bbbb0b1059659bd3caa7247e22af592f4bba6362 100644
|
| --- a/third_party/WebKit/LayoutTests/bluetooth/getPrimaryServices/gen-service-device-disconnects-invalidates-objects.html
|
| +++ b/third_party/WebKit/LayoutTests/bluetooth/script-tests/characteristic-device-disconnects-invalidates-objects.js
|
| @@ -1,9 +1,3 @@
|
| -<!-- Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py -->
|
| -<!DOCTYPE html>
|
| -<script src="../../resources/testharness.js"></script>
|
| -<script src="../../resources/testharnessreport.js"></script>
|
| -<script src="../../resources/bluetooth/bluetooth-helpers.js"></script>
|
| -<script>
|
| 'use strict';
|
| promise_test(() => {
|
| return setBluetoothFakeAdapter('DisconnectingHealthThermometerAdapter')
|
| @@ -12,44 +6,46 @@ promise_test(() => {
|
| optionalServices: [request_disconnection_service_uuid]}))
|
| .then(device => device.gatt.connect())
|
| .then(gattServer => {
|
| - let services;
|
| - return gattServer
|
| - .getPrimaryServices()
|
| - .then(s => {
|
| + let characteristics;
|
| + return gattServer.getPrimaryService('health_thermometer')
|
| + .then(service => service.CALLS([
|
| + getCharacteristic('measurement_interval')|
|
| + getCharacteristics()|
|
| + getCharacteristics('measurement_interval')[UUID]]))
|
| + .then(c => {
|
| // Convert to array if necessary.
|
| - services = [].concat(s);
|
| + characteristics = [].concat(c);
|
| return get_request_disconnection(gattServer);
|
| })
|
| .then(requestDisconnection => requestDisconnection())
|
| .then(() => gattServer.connect())
|
| - .then(() => services);
|
| + .then(() => characteristics);
|
| })
|
| - .then(services => {
|
| + .then(characteristics => {
|
| let promises = Promise.resolve();
|
| - for (let service of services) {
|
| - if (service.uuid == request_disconnection_service_uuid) {
|
| - continue;
|
| - }
|
| + for (let characteristic of characteristics) {
|
| let error = new DOMException(
|
| - 'Service is no longer valid. Remember to retrieve the service ' +
|
| - 'again after reconnecting.',
|
| + 'Characteristic is no longer valid. Remember to retrieve the ' +
|
| + 'characteristic again after reconnecting.',
|
| 'InvalidStateError');
|
| promises = promises.then(() =>
|
| assert_promise_rejects_with_message(
|
| - service.getCharacteristic('measurement_interval'),
|
| + characteristic.readValue(),
|
| error));
|
| promises = promises.then(() =>
|
| assert_promise_rejects_with_message(
|
| - service.getCharacteristics(),
|
| + characteristic.writeValue(new Uint8Array([1])),
|
| error));
|
| promises = promises.then(() =>
|
| assert_promise_rejects_with_message(
|
| - service.getCharacteristics('measurement_interval'),
|
| + characteristic.startNotifications(),
|
| + error));
|
| + promises = promises.then(() =>
|
| + assert_promise_rejects_with_message(
|
| + characteristic.stopNotifications(),
|
| error));
|
| }
|
| return promises;
|
| });
|
| -}, 'Calls on services after device disconnects and we reconnect. ' +
|
| +}, 'Calls on characteristics after device disconnects and we reconnect. ' +
|
| 'Should reject with InvalidStateError.');
|
| -
|
| -</script>
|
|
|