| 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 return gattServer.getPrimaryService('health_thermometer') | |
| 16 .then(service => service.getCharacteristic('measurement_interval')) | |
| 17 .then(c => { | |
| 18 // Convert to array if necessary. | |
| 19 let characteristics = [].concat(c); | |
| 20 gattServer.disconnect(); | |
| 21 return gattServer.connect() | |
| 22 .then(() => characteristics); | |
| 23 }); | |
| 24 }) | |
| 25 .then(characteristics => { | |
| 26 let promises = Promise.resolve(); | |
| 27 for (let characteristic of characteristics) { | |
| 28 let error = new DOMException( | |
| 29 'Characteristic is no longer valid. Remember to retrieve the ' + | |
| 30 'characteristic again after reconnecting.', | |
| 31 'InvalidStateError'); | |
| 32 promises = promises.then(() => | |
| 33 assert_promise_rejects_with_message( | |
| 34 characteristic.readValue(), | |
| 35 error)); | |
| 36 promises = promises.then(() => | |
| 37 assert_promise_rejects_with_message( | |
| 38 characteristic.writeValue(new Uint8Array([1])), | |
| 39 error)); | |
| 40 promises = promises.then(() => | |
| 41 assert_promise_rejects_with_message( | |
| 42 characteristic.startNotifications(), | |
| 43 error)); | |
| 44 promises = promises.then(() => | |
| 45 assert_promise_rejects_with_message( | |
| 46 characteristic.stopNotifications(), | |
| 47 error)); | |
| 48 } | |
| 49 return promises; | |
| 50 }); | |
| 51 }, 'Calls on characteristics after we disconnects and connect again. ' + | |
| 52 'Should reject with InvalidStateError.'); | |
| 53 | |
| 54 </script> | |
| OLD | NEW |