Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /infrastructure/testdriver/bidi/bluetooth/simulate_descriptor.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8" />
<meta name="timeout" content="long">
<title>TestDriver bidi.bluetooth.simulate_descriptor method</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js?feature=bidi"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/bidi-bluetooth-helper.js"></script>
<script>
promise_setup(async () => {
await test_driver.bidi.bluetooth.request_device_prompt_updated.subscribe();
await test_driver.bidi.bluetooth.gatt_connection_attempted.subscribe();
});
bluetooth_test(async (t) => {
const handle_prompt_promise = selectFirstDeviceOnDevicePromptUpdated();
const [device] = await Promise.all([requestDeviceWithTrustedClick({
acceptAllDevices: true,
optionalServices: [HEART_RATE_SERVICE_UUID]
}), handle_prompt_promise]);
await createGattConnection(device);
await test_driver.bidi.bluetooth.simulate_service({
address: DEVICE_ADDRESS,
uuid: HEART_RATE_SERVICE_UUID,
type: 'add',
});
await test_driver.bidi.bluetooth.simulate_characteristic({
address: DEVICE_ADDRESS,
serviceUuid: HEART_RATE_SERVICE_UUID,
characteristicUuid: DATE_TIME_CHARACTERISTIC_UUID,
characteristicProperties: {
'read': true
},
type: 'add',
});
await test_driver.bidi.bluetooth.simulate_descriptor({
address: DEVICE_ADDRESS,
serviceUuid: HEART_RATE_SERVICE_UUID,
characteristicUuid: DATE_TIME_CHARACTERISTIC_UUID,
descriptorUuid: CHARACTERISTIC_USER_DESCRIPTION_DESCRIPTOR_UUID,
type: 'add',
});
service = await device.gatt.getPrimaryService(HEART_RATE_SERVICE_UUID);
characteristic = await service.getCharacteristic(DATE_TIME_CHARACTERISTIC_UUID);
descriptors = await characteristic.getDescriptors();
assert_equals(
JSON.stringify(descriptors.map(descriptor => descriptor.uuid)),
JSON.stringify([CHARACTERISTIC_USER_DESCRIPTION_DESCRIPTOR_UUID])
);
}, "simulate a GATT descriptor.");
</script>