| OLD | NEW |
| (Empty) |
| 1 <!-- Generated by //third_party/WebKit/LayoutTests/bluetooth/generate.py --> | |
| 2 <!DOCTYPE html> | |
| 3 <script src="../../resources/testharness.js"></script> | |
| 4 <script src="../../resources/testharnessreport.js"></script> | |
| 5 <script src="../../resources/bluetooth/bluetooth-helpers.js"></script> | |
| 6 <script> | |
| 7 'use strict'; | |
| 8 promise_test(() => { | |
| 9 return setBluetoothFakeAdapter('DisconnectingHealthThermometerAdapter') | |
| 10 .then(() => requestDeviceWithKeyDown({ | |
| 11 filters: [{services: ['health_thermometer']}], | |
| 12 optionalServices: [request_disconnection_service_uuid]})) | |
| 13 .then(device => device.gatt.connect()) | |
| 14 .then(gattServer => { | |
| 15 let characteristics; | |
| 16 return gattServer.getPrimaryService('health_thermometer') | |
| 17 .then(service => service.getCharacteristics('measurement_interval')) | |
| 18 .then(c => { | |
| 19 // Convert to array if necessary. | |
| 20 characteristics = [].concat(c); | |
| 21 return get_request_disconnection(gattServer); | |
| 22 }) | |
| 23 .then(requestDisconnection => requestDisconnection()) | |
| 24 .then(() => gattServer.connect()) | |
| 25 .then(() => characteristics); | |
| 26 }) | |
| 27 .then(characteristics => { | |
| 28 let promises = Promise.resolve(); | |
| 29 for (let characteristic of characteristics) { | |
| 30 let error = new DOMException( | |
| 31 'Characteristic is no longer valid. Remember to retrieve the ' + | |
| 32 'characteristic again after reconnecting.', | |
| 33 'InvalidStateError'); | |
| 34 promises = promises.then(() => | |
| 35 assert_promise_rejects_with_message( | |
| 36 characteristic.readValue(), | |
| 37 error)); | |
| 38 promises = promises.then(() => | |
| 39 assert_promise_rejects_with_message( | |
| 40 characteristic.writeValue(new Uint8Array([1])), | |
| 41 error)); | |
| 42 promises = promises.then(() => | |
| 43 assert_promise_rejects_with_message( | |
| 44 characteristic.startNotifications(), | |
| 45 error)); | |
| 46 promises = promises.then(() => | |
| 47 assert_promise_rejects_with_message( | |
| 48 characteristic.stopNotifications(), | |
| 49 error)); | |
| 50 } | |
| 51 return promises; | |
| 52 }); | |
| 53 }, 'Calls on characteristics after device disconnects and we reconnect. ' + | |
| 54 'Should reject with InvalidStateError.'); | |
| 55 | |
| 56 </script> | |
| OLD | NEW |