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