| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script src="../../resources/bluetooth/bluetooth-helpers.js"></script> | 4 <script src="../../resources/bluetooth/bluetooth-helpers.js"></script> |
| 5 <script> | 5 <script> |
| 6 'use strict'; | 6 'use strict'; |
| 7 promise_test(() => { | 7 promise_test(() => { |
| 8 let char; | |
| 9 return setBluetoothFakeAdapter('HeartRateAdapter') | 8 return setBluetoothFakeAdapter('HeartRateAdapter') |
| 10 .then(() => requestDeviceWithKeyDown({ | 9 .then(() => requestDeviceWithKeyDown({ |
| 11 filters: [{services: ['heart_rate']}]})) | 10 filters: [{services: ['heart_rate']}]})) |
| 12 .then(device => device.gatt.connect()) | 11 .then(device => device.gatt.connect()) |
| 13 .then(gattServer => gattServer.getPrimaryService('heart_rate')) | 12 .then(gattServer => gattServer.getPrimaryService('heart_rate')) |
| 14 .then(service => service.getCharacteristic('heart_rate_measurement')) | 13 .then(service => service.getCharacteristic('body_sensor_location')) |
| 15 .then(characteristic => { | 14 .then(characteristic => { |
| 16 char = characteristic; | |
| 17 return assert_event_fires_after_promise(characteristic, | 15 return assert_event_fires_after_promise(characteristic, |
| 18 'startNotifications', | 16 'readValue', |
| 19 'characteristicvaluechanged', | 17 'characteristicvaluechanged'); |
| 20 3 /* add 3 listeners */); | 18 }).then(results => { |
| 21 }) | 19 let read_value = results[0].buffer; |
| 22 .then(() => char.stopNotifications()) | 20 let event_value = results[1].buffer; |
| 23 .then(() => assert_no_events(char, 'characteristicvaluechanged')); | 21 // TODO(ortuno): The DataView used to resolve the promise |
| 24 }, 'Add multiple event listeners then startNotifications().'); | 22 // should be the same DataView as the one saved in the |
| 23 // characteristic. |
| 24 // http://crbug.com/543347 |
| 25 // assert_equals(event.target.value, value); |
| 26 assert_array_equals(event_value, read_value); |
| 27 }); |
| 28 }, 'Reading a characteristic should fire an event.'); |
| 25 </script> | 29 </script> |
| OLD | NEW |