Auto merge of #13184 - szeged:requestdevice-refactor, r=jdm

Webbluetooth requestDevice refactor and update

<!-- Please describe your changes on the following line: -->
Refactor requestDevice function according to the specification changes.
1. Moved the `request_bluetooth_devices` algorithm out from the `requestDevice` function.
2. Two new members in `BluetoothRequestDeviceFilter` and one new member in `RequestDeviceOptions`.
3. Also added annotations to the related functions.
Related links:
https://webbluetoothcg.github.io/web-bluetooth/#device-discovery,
https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice, https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices,
https://webbluetoothcg.github.io/web-bluetooth/#matches-a-filter

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #12614

<!-- Either: -->
- [x] These changes do not require tests because , there is no WebBluetooth Test API implementation yet.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13184)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-09-15 17:29:44 -05:00 committed by GitHub
commit 8334020a87
5 changed files with 306 additions and 100 deletions

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<title>Request All Devices</title>
<body>
<button type="button" onclick="onButtonClick()">Request All Devices</button>
<pre id="log"></pre>
<script src="bluetooth_functions.js"></script>
<script>
function onButtonClick() {
clear();
var options = {optionalServices: ['generic_access'], acceptAllDevices:true};
try {
log('Requesting Bluetooth Device...');
var bluetooth = window.navigator.bluetooth;
var device = bluetooth.requestDevice(options);
log('Connecting to GATT Server on device...');
var server = device.gatt.connect();
log('Getting Generic Access Service...');
var service = server.getPrimaryService('generic_access');
} catch(err) {
log(err);
}
}
</script>
</body>
</html>