Auto merge of #13428 - szeged:wbt_promise, r=jdm

Update WebBluetooth to use Promises

<!-- Please describe your changes on the following line: -->
Initial patch to support promises in WebBluetooth.
This will allow us to use the expected syntax in webpages.

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/13428)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-10-01 06:18:59 -05:00 committed by GitHub
commit 0c80ac9a1b
32 changed files with 684 additions and 458 deletions

View file

@ -23,9 +23,7 @@ interface Bluetooth {
// [SecureContext]
// readonly attribute BluetoothDevice? referringDevice;
// [SecureContext]
// Promise<BluetoothDevice> requestDevice(RequestDeviceOptions options);
[Throws]
BluetoothDevice requestDevice(optional RequestDeviceOptions options);
Promise<BluetoothDevice> requestDevice(optional RequestDeviceOptions options);
};
// Bluetooth implements EventTarget;

View file

@ -10,18 +10,12 @@ interface BluetoothRemoteGATTCharacteristic {
readonly attribute DOMString uuid;
readonly attribute BluetoothCharacteristicProperties properties;
readonly attribute ByteString? value;
[Throws]
BluetoothRemoteGATTDescriptor getDescriptor(BluetoothDescriptorUUID descriptor);
[Throws]
sequence<BluetoothRemoteGATTDescriptor> getDescriptors(optional BluetoothDescriptorUUID descriptor);
//Promise<BluetoothRemoteGATTDescriptor> getDescriptor(BluetoothDescriptorUUID descriptor);
//Promise<sequence<BluetoothRemoteGATTDescriptor>>
//getDescriptors(optional BluetoothDescriptorUUID descriptor);
[Throws]
ByteString readValue();
Promise<BluetoothRemoteGATTDescriptor> getDescriptor(BluetoothDescriptorUUID descriptor);
Promise<sequence<BluetoothRemoteGATTDescriptor>>
getDescriptors(optional BluetoothDescriptorUUID descriptor);
Promise<ByteString> readValue();
//Promise<DataView> readValue();
[Throws]
void writeValue(sequence<octet> value);
Promise<void> writeValue(sequence<octet> value);
//Promise<void> writeValue(BufferSource value);
//Promise<void> startNotifications();
//Promise<void> stopNotifications();

View file

@ -9,10 +9,8 @@ interface BluetoothRemoteGATTDescriptor {
readonly attribute BluetoothRemoteGATTCharacteristic characteristic;
readonly attribute DOMString uuid;
readonly attribute ByteString? value;
[Throws]
ByteString readValue();
Promise<ByteString> readValue();
//Promise<DataView> readValue();
[Throws]
void writeValue(sequence<octet> value);
Promise<void> writeValue(sequence<octet> value);
//Promise<void> writeValue(BufferSource value);
};

View file

@ -8,15 +8,9 @@
interface BluetoothRemoteGATTServer {
readonly attribute BluetoothDevice device;
readonly attribute boolean connected;
[Throws]
BluetoothRemoteGATTServer connect();
Promise<BluetoothRemoteGATTServer> connect();
[Throws]
void disconnect();
[Throws]
BluetoothRemoteGATTService getPrimaryService(BluetoothServiceUUID service);
[Throws]
sequence<BluetoothRemoteGATTService> getPrimaryServices(optional BluetoothServiceUUID service);
//Promise<BluetoothRemoteGATTService> getPrimaryService(BluetoothServiceUUID service);
//Promise<sequence<BluetoothRemoteGATTService>>getPrimaryServices(optional BluetoothServiceUUID service);
//Promise<BluetoothRemoteGATTServer> connect();
Promise<BluetoothRemoteGATTService> getPrimaryService(BluetoothServiceUUID service);
Promise<sequence<BluetoothRemoteGATTService>> getPrimaryServices(optional BluetoothServiceUUID service);
};

View file

@ -9,18 +9,9 @@ interface BluetoothRemoteGATTService {
readonly attribute BluetoothDevice device;
readonly attribute DOMString uuid;
readonly attribute boolean isPrimary;
[Throws]
BluetoothRemoteGATTCharacteristic getCharacteristic(BluetoothCharacteristicUUID characteristic);
[Throws]
sequence<BluetoothRemoteGATTCharacteristic> getCharacteristics
(optional BluetoothCharacteristicUUID characteristic);
//Promise<BluetoothRemoteGATTCharacteristic>getCharacteristic(BluetoothCharacteristicUUID characteristic);
//Promise<sequence<BluetoothRemoteGATTCharacteristic>>
//getCharacteristics(optional BluetoothCharacteristicUUID characteristic);
[Throws]
BluetoothRemoteGATTService getIncludedService(BluetoothServiceUUID service);
[Throws]
sequence<BluetoothRemoteGATTService> getIncludedServices(optional BluetoothServiceUUID service);
//Promise<BluetoothRemoteGATTService>getIncludedService(BluetoothServiceUUID service);
//Promise<sequence<BluetoothRemoteGATTService>>getIncludedServices(optional BluetoothServiceUUID service);
Promise<BluetoothRemoteGATTCharacteristic> getCharacteristic(BluetoothCharacteristicUUID characteristic);
Promise<sequence<BluetoothRemoteGATTCharacteristic>>
getCharacteristics(optional BluetoothCharacteristicUUID characteristic);
Promise<BluetoothRemoteGATTService> getIncludedService(BluetoothServiceUUID service);
Promise<sequence<BluetoothRemoteGATTService>> getIncludedServices(optional BluetoothServiceUUID service);
};