blob: c67cb568d3aa94905f8cb562b8ac27c3733c3621 [file] [log] [blame]
<!-- Generated by //third_party/blink/web_tests/bluetooth/generate.py -->
<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/testdriver.js"></script>
<script src="../../../resources/testdriver-vendor.js"></script>
<script src="../../../external/wpt/bluetooth/resources/bluetooth-helpers.js"></script>
<script>
'use strict';
bluetooth_test(() => {
return setBluetoothFakeAdapter('DisconnectingDuringServiceRetrievalAdapter')
.then(() => requestDeviceWithTrustedClick({
filters: [{services: ['heart_rate']}],
optionalServices: ['battery_service']}
))
.then(device => device.gatt.connect())
.then(gatt => {
let disconnected = eventPromise(gatt.device, 'gattserverdisconnected');
let promise = assert_promise_rejects_with_message(
// TODO(crbug.com/719816): Add a call to getPrimaryServices() when
// the adapter doesn't include services.
gatt.getPrimaryServices('battery_service'),
new DOMException('GATT Server is disconnected. ' +
'Cannot retrieve services. ' +
'(Re)connect first with `device.gatt.connect`.',
'NetworkError'));
return disconnected.then(() => gatt.connect()).then(() => promise);
});
}, 'Device disconnects and we reconnect during a getPrimaryServices call ' +
'that fails. Reject with NetworkError.');
</script>