servo: Merge #14205 - Minor fixes for the WebBluetooth implementation (from szeged:minor-fixes); r=jdm
authorZakor Gyula <zakorgy@inf.u-szeged.hu>
Mon, 14 Nov 2016 13:50:51 -0600
changeset 340153 5f5394adc8ac6592687f31d4456396b1db6592f4
parent 340152 2bd553ec64624838f952212386bc347b691779cd
child 340154 23de2cbe2ec91dc8ec1a702e884c7d5a242c97c7
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
servo: Merge #14205 - Minor fixes for the WebBluetooth implementation (from szeged:minor-fixes); r=jdm <!-- Please describe your changes on the following line: --> 1. Fix for a comment typo in `bluetooth.rs `. 2. Simplify caling `self.request_bluetooth_devices` in `bluetooth.rs` in `Step 2`. We already have a check in `Step 1` to prevent calling `request_bluetooth_devices` with a `Some` value if `option.acceptAllDevices` is true, and `option.filters` is already an `Option`, so there is no need for the `None` in the else branch. 3. Updating the bluetooth extension in `Navigator.webidl `, to match the [specification](https://webbluetoothcg.github.io/web-bluetooth/#navigator-extensions). 4. Replace the `_` separating the characteristic property strings with `-` as described [here](http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt#n142) --- <!-- 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 <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 4f53626c23e0affc6fca3bf1f4f1f3c722f58074
servo/components/bluetooth/lib.rs
servo/components/script/dom/bluetooth.rs
servo/components/script/dom/webidls/Navigator.webidl
--- a/servo/components/bluetooth/lib.rs
+++ b/servo/components/bluetooth/lib.rs
@@ -460,23 +460,23 @@ impl BluetoothManager {
 
     fn get_characteristic_properties(&self, characteristic: &BluetoothGATTCharacteristic) -> Flags {
         let mut props: Flags = Flags::empty();
         let flags = characteristic.get_flags().unwrap_or(vec!());
         for flag in flags {
             match flag.as_ref() {
                 "broadcast" => props.insert(BROADCAST),
                 "read" => props.insert(READ),
-                "write_without_response" => props.insert(WRITE_WITHOUT_RESPONSE),
+                "write-without-response" => props.insert(WRITE_WITHOUT_RESPONSE),
                 "write" => props.insert(WRITE),
                 "notify" => props.insert(NOTIFY),
                 "indicate" => props.insert(INDICATE),
-                "authenticated_signed_writes" => props.insert(AUTHENTICATED_SIGNED_WRITES),
-                "reliable_write" => props.insert(RELIABLE_WRITE),
-                "writable_auxiliaries" => props.insert(WRITABLE_AUXILIARIES),
+                "authenticated-signed-writes" => props.insert(AUTHENTICATED_SIGNED_WRITES),
+                "reliable-write" => props.insert(RELIABLE_WRITE),
+                "writable-auxiliaries" => props.insert(WRITABLE_AUXILIARIES),
                 _ => (),
             }
         }
         props
     }
 
     // Descriptor
 
--- a/servo/components/script/dom/bluetooth.rs
+++ b/servo/components/script/dom/bluetooth.rs
@@ -189,17 +189,17 @@ fn convert_request_device_options(filter
     let mut optional_services_uuids = vec!();
     if let &Some(ref opt_services) = optional_services {
         for opt_service in opt_services {
             // Step 2.5 - 2.6.
             let uuid = try!(BluetoothUUID::service(opt_service.clone())).to_string();
 
             // Step 2.7.
             // Note: What we are doing here is adding the not blacklisted UUIDs to the result vector,
-            // insted of removing them from an already filled vector.
+            // instead of removing them from an already filled vector.
             if !uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) {
                 optional_services_uuids.push(uuid);
             }
         }
     }
 
     Ok(RequestDeviceoptions::new(BluetoothScanfilterSequence::new(uuid_filters),
                                  ServiceUUIDSequence::new(optional_services_uuids)))
@@ -332,21 +332,17 @@ impl BluetoothMethods for Bluetooth {
         let p = Promise::new(&self.global());
         // Step 1.
         if (option.filters.is_some() && option.acceptAllDevices) ||
            (option.filters.is_none() && !option.acceptAllDevices) {
             p.reject_error(p.global().get_cx(), Error::Type(OPTIONS_ERROR.to_owned()));
             return p;
         }
         // Step 2.
-        if !option.acceptAllDevices {
-            self.request_bluetooth_devices(&p, &option.filters, &option.optionalServices);
-        } else {
-            self.request_bluetooth_devices(&p, &None, &option.optionalServices);
-        }
+        self.request_bluetooth_devices(&p, &option.filters, &option.optionalServices);
         // TODO(#4282): Step 3-5: Reject and resolve promise.
         return p;
     }
 }
 
 impl AsyncBluetoothListener for Bluetooth {
     fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
         match response {
--- a/servo/components/script/dom/webidls/Navigator.webidl
+++ b/servo/components/script/dom/webidls/Navigator.webidl
@@ -2,17 +2,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // https://html.spec.whatwg.org/multipage/#navigator
 interface Navigator {
   // objects implementing this interface also implement the interfaces given below
 };
 Navigator implements NavigatorID;
-Navigator implements NavigatorBluetooth;
 Navigator implements NavigatorLanguage;
 //Navigator implements NavigatorOnLine;
 //Navigator implements NavigatorContentUtils;
 //Navigator implements NavigatorStorageUtils;
 Navigator implements NavigatorPlugins;
 Navigator implements NavigatorCookies;
 
 // https://html.spec.whatwg.org/multipage/#navigatorid
@@ -22,19 +21,19 @@ interface NavigatorID {
   readonly attribute DOMString appName;
   readonly attribute DOMString appVersion;
   readonly attribute DOMString platform;
   readonly attribute DOMString product; // constant "Gecko"
   boolean taintEnabled(); // constant false
   readonly attribute DOMString userAgent;
 };
 
-[NoInterfaceObject]
-interface NavigatorBluetooth {
-    readonly attribute Bluetooth bluetooth;
+// https://webbluetoothcg.github.io/web-bluetooth/#navigator-extensions
+partial interface Navigator {
+  readonly attribute Bluetooth bluetooth;
 };
 
 // https://w3c.github.io/ServiceWorker/#navigator-service-worker
 partial interface Navigator {
   [SameObject, Pref="dom.serviceworker.enabled"] readonly attribute ServiceWorkerContainer serviceWorker;
 };
 
 // https://html.spec.whatwg.org/multipage/#navigatorlanguage