| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script src="../../resources/bluetooth/bluetooth-helpers.js"></script> |
| 5 <script> |
| 6 'use strict'; |
| 7 promise_test(() => { |
| 8 function assert_expected_events(events) { |
| 9 assert_equals(events.length, 4); |
| 10 assert_equals(events[0], 'chooser-opened(file://)'); |
| 11 let idsByName = new AddDeviceEventSet(); |
| 12 idsByName.assert_add_device_event(events[1]); |
| 13 assert_true(idsByName.has('Heart Rate Device')); |
| 14 assert_equals(events[2], 'discovering'); |
| 15 assert_equals(events[3], 'discovery-idle'); |
| 16 return idsByName; |
| 17 }; |
| 18 |
| 19 testRunner.setBluetoothManualChooser(true); |
| 20 // Open a chooser. |
| 21 let firstRequestDevicePromise = setBluetoothFakeAdapter('HeartRateAdapter') |
| 22 .then(() => assert_promise_rejects_with_message( |
| 23 requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}), |
| 24 new DOMException('User cancelled the requestDevice() chooser.', |
| 25 'NotFoundError'))); |
| 26 |
| 27 return getBluetoothManualChooserEvents(4) |
| 28 .then(assert_expected_events) |
| 29 .then(() => { |
| 30 // Open another chooser. |
| 31 let secondRequestDevicePromise = |
| 32 requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| 33 .then(device => assert_equals(device.constructor.name, |
| 34 'BluetoothDevice')); |
| 35 return getBluetoothManualChooserEvents(4) |
| 36 .then(assert_expected_events) |
| 37 .then(idsByName => { |
| 38 testRunner.sendBluetoothManualChooserEvent( |
| 39 'selected', idsByName.get('Heart Rate Device')); |
| 40 return Promise.all([ |
| 41 firstRequestDevicePromise, |
| 42 secondRequestDevicePromise]); |
| 43 }); |
| 44 }); |
| 45 }, 'A second call to requestDevice with the chooser opened will close the ' + |
| 46 'previous chooser.'); |
| 47 </script> |
| OLD | NEW |