The Web Bluetooth API enables sites to connect to and interact with Bluetooth Low Energy devices. Please check the Web Bluetooth specification for more details.
Web Bluetooth testing relies on the FakeBluetooth test API which must be provided by browsers under test.
In this test suite
resources/bluetooth-test.js detects and triggers the API to be loaded as needed. This file also contains test helper methods, such as for asserting that Bluetooth events are fired in a specific order. The
resources/bluetooth-fake-devices.js contains several helper methods that set up fake Bluetooth devices.
Several Web Bluetooth tests share common test logic. For these tests, the
script-tests directory contains templates that are used by the
CALLS() keyword with functions delimited by a
| character. A test will be created for each function in the
generate.py. Note that for each subdirectory in
script-tests there is a matching directory under
bluetooth. The generator will expand
CALLS functions into the corresponding directory.
./script-tests/server/get-same-object.js contains the following code:
gattServer.CALLS([ getPrimaryService('heart_rate')| getPrimaryServices()| getPrimaryServices('heart_rate')[UUID]]),
The functions in
CALLS() will be expanded to generate 3 test files prefixed with
bluetooth/server/getPrimaryService/gen-get-same-object.html bluetooth/server/getPrimaryServices/gen-get-same-object.html bluetooth/server/getPrimaryServices/gen-get-same-object-with-uuid.html
To generate the tests in
script-tests, run the following command from the source root:
$ python bluetooth/generate.py
To check that generated tests are correct and that there are no obsolete tests, or tests for which a template does not exist anymore, run:
$ python bluetooth/generate_test.py
More details can be found in
The Chromium implementation is provided by
The Chromium implementation is not included in stable Chrome builds since it would add too much to the binary size. On Chromium infrastructure, it is run using the
In the future, Chromium
src/device/bluetooth may be refactored into a Mojo service. At this point, it would be possible to add the necessary testing hooks into stable Chrome without substantially increasing the binary size, similar to WebUSB.
These Bluetooth tests are upstreamed here because other browsers can reuse them by implementing the Web Bluetooth Testing API, even if only on their internal infrastructure.
For more implementation details, see the Web Bluetooth Service README.
For any issues pertaining to the specification, please file a GitHub issue. For issues pertaining to an implementation of Web Bluetooth, please file an issue with the implementor's bug tracker.
Mailing list: email@example.com
Bug tracker: Blink>Bluetooth