| OLD | NEW |
| 1 'use strict'; | 1 'use strict'; |
| 2 promise_test(() => { | 2 promise_test(() => { |
| 3 return setBluetoothFakeAdapter('DisconnectingHealthThermometerAdapter') | 3 return setBluetoothFakeAdapter('DisconnectingHealthThermometerAdapter') |
| 4 .then(() => requestDeviceWithKeyDown({ | 4 .then(() => requestDeviceWithKeyDown({ |
| 5 filters: [{services: ['health_thermometer']}], | 5 filters: [{services: ['health_thermometer']}], |
| 6 optionalServices: [request_disconnection_service_uuid]})) | 6 optionalServices: [request_disconnection_service_uuid]})) |
| 7 .then(device => device.gatt.connect()) | 7 .then(device => device.gatt.connect()) |
| 8 .then(gattServer => { | 8 .then(gattServer => { |
| 9 return gattServer.getPrimaryService('health_thermometer') | 9 return gattServer.getPrimaryService('health_thermometer') |
| 10 .then(service => service.CALLS([ | 10 .then(service => service.CALLS([ |
| 11 getCharacteristic('measurement_interval')| | 11 getCharacteristic('measurement_interval')| |
| 12 getCharacteristics()| | 12 getCharacteristics()| |
| 13 getCharacteristics('measurement_interval')[UUID]])) | 13 getCharacteristics('measurement_interval')[UUID]])) |
| 14 .then(c => { | 14 .then(c => { |
| 15 // Convert to array if necessary. | 15 // Convert to array if necessary. |
| 16 let characteristics = [].concat(c); | 16 let characteristics = [].concat(c); |
| 17 gattServer.disconnect(); | 17 gattServer.disconnect(); |
| 18 return gattServer.connect() | 18 return gattServer.connect() |
| 19 .then(() => characteristics); | 19 .then(() => characteristics); |
| 20 }); | 20 }); |
| 21 }) | 21 }) |
| 22 .then(characteristics => { | 22 .then(characteristics => { |
| 23 let promises = Promise.resolve(); | 23 let promises = Promise.resolve(); |
| 24 for (let characteristic of characteristics) { | 24 for (let characteristic of characteristics) { |
| 25 let error = new DOMException( | 25 let error = new DOMException( |
| 26 'Characteristic is no longer valid. Remember to retrieve the ' + | 26 'Characteristic with UUID ' + characteristic.uuid + |
| 27 ' is no longer valid. Remember to retrieve the ' + |
| 27 'characteristic again after reconnecting.', | 28 'characteristic again after reconnecting.', |
| 28 'InvalidStateError'); | 29 'InvalidStateError'); |
| 29 promises = promises.then(() => | 30 promises = promises.then(() => |
| 30 assert_promise_rejects_with_message( | 31 assert_promise_rejects_with_message( |
| 31 characteristic.readValue(), | 32 characteristic.readValue(), |
| 32 error)); | 33 error)); |
| 33 promises = promises.then(() => | 34 promises = promises.then(() => |
| 34 assert_promise_rejects_with_message( | 35 assert_promise_rejects_with_message( |
| 35 characteristic.writeValue(new Uint8Array([1])), | 36 characteristic.writeValue(new Uint8Array([1])), |
| 36 error)); | 37 error)); |
| 37 promises = promises.then(() => | 38 promises = promises.then(() => |
| 38 assert_promise_rejects_with_message( | 39 assert_promise_rejects_with_message( |
| 39 characteristic.startNotifications(), | 40 characteristic.startNotifications(), |
| 40 error)); | 41 error)); |
| 41 promises = promises.then(() => | 42 promises = promises.then(() => |
| 42 assert_promise_rejects_with_message( | 43 assert_promise_rejects_with_message( |
| 43 characteristic.stopNotifications(), | 44 characteristic.stopNotifications(), |
| 44 error)); | 45 error)); |
| 45 } | 46 } |
| 46 return promises; | 47 return promises; |
| 47 }); | 48 }); |
| 48 }, 'Calls on characteristics after we disconnects and connect again. ' + | 49 }, 'Calls on characteristics after we disconnects and connect again. ' + |
| 49 'Should reject with InvalidStateError.'); | 50 'Should reject with InvalidStateError.'); |
| OLD | NEW |