blob: d946f1783d1eac2d099543d599f4a886467da45a [file] [log] [blame]
<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
bluetooth_test(() => {
setBluetoothManualChooser(true);
let requestDevicePromise =
setBluetoothFakeAdapter('DevicesRemovedAdapter')
.then(() => requestDeviceWithKeyDown({
filters: [{services: ['glucose']},
{services: ['heart_rate']}]}));
return assert_promise_rejects_with_message(
getBluetoothManualChooserEvents(5).then(events => {
assert_equals(events[0], 'chooser-opened(file://)');
let idsByName = new AddDeviceEventSet();
idsByName.assert_add_device_event(events[1]);
assert_true(idsByName.has('Connected Heart Rate Device'), events[1]);
assert_equals(events[2], 'discovering');
idsByName.assert_add_device_event(events[3]);
assert_true(idsByName.has('New Glucose Device'));
assert_equals(events[4], 'discovery-idle');
sendBluetoothManualChooserEvent(
'selected', idsByName.get('New Glucose Device'));
return requestDevicePromise;
}), new DOMException('User selected a device that doesn\'t exist anymore.',
'NotFoundError'));
// TODO(crbug.com/654649): Chooser should receive a signal that the device
// was removed and grey out/disable the row.
}, 'Devices are added and removed. Chooser should not get a signal that the ' +
'device was removed and promise should be rejected when a removed device ' +
'is selected.');
</script>