aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAttila Dusnoki <dati91@gmail.com>2016-03-02 15:00:13 +0100
committerAttila Dusnoki <dati91@gmail.com>2016-03-16 10:34:48 +0100
commite7d70cfabf5ad412045fd4088379afd1bedfaece (patch)
tree864717991d59edd654547256df45dd60f099f61b
parent00628704ca5f3318a4b97b7586cd17b31eabf5f6 (diff)
downloadservo-e7d70cfabf5ad412045fd4088379afd1bedfaece.tar.gz
servo-e7d70cfabf5ad412045fd4088379afd1bedfaece.zip
WebBluetooth API classes
-rw-r--r--components/script/Cargo.toml1
-rw-r--r--components/script/dom/bluetooth.rs39
-rw-r--r--components/script/dom/bluetoothadvertisingdata.rs54
-rw-r--r--components/script/dom/bluetoothcharacteristicproperties.rs122
-rw-r--r--components/script/dom/bluetoothdevice.rs125
-rw-r--r--components/script/dom/bluetoothremotegattcharacteristic.rs87
-rw-r--r--components/script/dom/bluetoothremotegattdescriptor.rs68
-rw-r--r--components/script/dom/bluetoothremotegattserver.rs70
-rw-r--r--components/script/dom/bluetoothremotegattservice.rs70
-rw-r--r--components/script/dom/bluetoothuuid.rs116
-rw-r--r--components/script/dom/mod.rs9
-rw-r--r--components/script/dom/navigator.rs14
-rw-r--r--components/script/dom/webidls/Bluetooth.webidl15
-rw-r--r--components/script/dom/webidls/BluetoothAdvertisingData.webidl22
-rw-r--r--components/script/dom/webidls/BluetoothCharacteristicProperties.webidl18
-rw-r--r--components/script/dom/webidls/BluetoothDevice.webidl30
-rw-r--r--components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl25
-rw-r--r--components/script/dom/webidls/BluetoothRemoteGATTDescriptor.webidl16
-rw-r--r--components/script/dom/webidls/BluetoothRemoteGATTServer.webidl17
-rw-r--r--components/script/dom/webidls/BluetoothRemoteGATTService.webidl18
-rw-r--r--components/script/dom/webidls/BluetoothUUID.webidl21
-rw-r--r--components/script/dom/webidls/Navigator.webidl6
-rw-r--r--components/script/lib.rs1
-rw-r--r--components/servo/Cargo.lock19
-rw-r--r--ports/cef/Cargo.lock19
-rw-r--r--ports/gonk/Cargo.lock15
-rw-r--r--python/tidy.py1
-rw-r--r--tests/wpt/mozilla/tests/mozilla/interfaces.html9
28 files changed, 999 insertions, 28 deletions
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml
index 709ced84779..705097c9144 100644
--- a/components/script/Cargo.toml
+++ b/components/script/Cargo.toml
@@ -82,6 +82,7 @@ rand = "0.3"
phf = "0.7.13"
phf_macros = "0.7.13"
ref_slice = "0.1.0"
+regex = "0.1.43"
rustc-serialize = "0.3"
selectors = {version = "0.5", features = ["heap_size"]}
serde = "0.6"
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs
new file mode 100644
index 00000000000..58d506dec45
--- /dev/null
+++ b/components/script/dom/bluetooth.rs
@@ -0,0 +1,39 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+use dom::bindings::codegen::Bindings::BluetoothBinding;
+use dom::bindings::codegen::Bindings::BluetoothBinding::BluetoothMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::Root;
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::bluetoothdevice::BluetoothDevice;
+
+// https://webbluetoothcg.github.io/web-bluetooth/#bluetooth
+#[dom_struct]
+pub struct Bluetooth {
+ reflector_: Reflector,
+}
+
+impl Bluetooth {
+ pub fn new_inherited() -> Bluetooth {
+ Bluetooth {
+ reflector_: Reflector::new(),
+ }
+ }
+
+ pub fn new(global: GlobalRef) -> Root<Bluetooth> {
+ reflect_dom_object(box Bluetooth::new_inherited(),
+ global,
+ BluetoothBinding::Wrap)
+ }
+}
+
+impl BluetoothMethods for Bluetooth {
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
+ fn RequestDevice(&self) -> Option<Root<BluetoothDevice>> {
+ //UNIMPLEMENTED
+ None
+ }
+}
diff --git a/components/script/dom/bluetoothadvertisingdata.rs b/components/script/dom/bluetoothadvertisingdata.rs
new file mode 100644
index 00000000000..71c1346fa3d
--- /dev/null
+++ b/components/script/dom/bluetoothadvertisingdata.rs
@@ -0,0 +1,54 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+use dom::bindings::codegen::Bindings::BluetoothAdvertisingDataBinding;
+use dom::bindings::codegen::Bindings::BluetoothAdvertisingDataBinding::BluetoothAdvertisingDataMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::Root;
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+
+// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingdata
+#[dom_struct]
+pub struct BluetoothAdvertisingData {
+ reflector_: Reflector,
+ appearance: u16,
+ txPower: i8,
+ rssi: i8,
+}
+
+impl BluetoothAdvertisingData {
+ pub fn new_inherited(appearance: u16, txPower: i8, rssi: i8) -> BluetoothAdvertisingData {
+ BluetoothAdvertisingData {
+ reflector_: Reflector::new(),
+ appearance: appearance,
+ txPower: txPower,
+ rssi: rssi,
+ }
+ }
+
+ pub fn new(global: GlobalRef, appearance: u16, txPower: i8, rssi: i8) -> Root<BluetoothAdvertisingData> {
+ reflect_dom_object(box BluetoothAdvertisingData::new_inherited(appearance,
+ txPower,
+ rssi),
+ global,
+ BluetoothAdvertisingDataBinding::Wrap)
+ }
+}
+
+impl BluetoothAdvertisingDataMethods for BluetoothAdvertisingData {
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingdata-appearance
+ fn GetAppearance(&self) -> Option<u16> {
+ Some(self.appearance)
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingdata-txpower
+ fn GetTxPower(&self) -> Option<i8> {
+ Some(self.txPower)
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothadvertisingdata-rssi
+ fn GetRssi(&self) -> Option<i8> {
+ Some(self.rssi)
+ }
+}
diff --git a/components/script/dom/bluetoothcharacteristicproperties.rs b/components/script/dom/bluetoothcharacteristicproperties.rs
new file mode 100644
index 00000000000..9abb5e5cd5b
--- /dev/null
+++ b/components/script/dom/bluetoothcharacteristicproperties.rs
@@ -0,0 +1,122 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding;
+use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
+ BluetoothCharacteristicPropertiesMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::Root;
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+
+// https://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties
+ #[dom_struct]
+pub struct BluetoothCharacteristicProperties {
+ reflector_: Reflector,
+ broadcast: bool,
+ read: bool,
+ writeWithoutResponse: bool,
+ write: bool,
+ notify: bool,
+ indicate: bool,
+ authenticatedSignedWrites: bool,
+ reliableWrite: bool,
+ writableAuxiliaries: bool,
+}
+
+impl BluetoothCharacteristicProperties {
+ pub fn new_inherited(broadcast: bool,
+ read: bool,
+ writeWithoutResponse: bool,
+ write: bool,
+ notify: bool,
+ indicate: bool,
+ authenticatedSignedWrites: bool,
+ reliableWrite: bool,
+ writableAuxiliaries: bool)
+ -> BluetoothCharacteristicProperties {
+ BluetoothCharacteristicProperties {
+ reflector_: Reflector::new(),
+ broadcast: broadcast,
+ read: read,
+ writeWithoutResponse: writeWithoutResponse,
+ write: write,
+ notify: notify,
+ indicate: indicate,
+ authenticatedSignedWrites: authenticatedSignedWrites,
+ reliableWrite: reliableWrite,
+ writableAuxiliaries: writableAuxiliaries,
+ }
+ }
+
+ pub fn new(global: GlobalRef,
+ broadcast: bool,
+ read: bool,
+ writeWithoutResponse: bool,
+ write: bool,
+ notify: bool,
+ indicate: bool,
+ authenticatedSignedWrites: bool,
+ reliableWrite: bool,
+ writableAuxiliaries: bool)
+ -> Root<BluetoothCharacteristicProperties> {
+ reflect_dom_object(box BluetoothCharacteristicProperties::new_inherited(broadcast,
+ read,
+ writeWithoutResponse,
+ write,
+ notify,
+ indicate,
+ authenticatedSignedWrites,
+ reliableWrite,
+ writableAuxiliaries),
+ global,
+ BluetoothCharacteristicPropertiesBinding::Wrap)
+ }
+ }
+
+impl BluetoothCharacteristicPropertiesMethods for BluetoothCharacteristicProperties {
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-broadcast
+ fn Broadcast(&self) -> bool {
+ self.broadcast
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-read
+ fn Read(&self) -> bool {
+ self.read
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-writewithoutresponse
+ fn WriteWithoutResponse(&self) -> bool {
+ self.writeWithoutResponse
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-write
+ fn Write(&self) -> bool {
+ self.write
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-notify
+ fn Notify(&self) -> bool {
+ self.notify
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-indicate
+ fn Indicate(&self) -> bool {
+ self.indicate
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-authenticatedsignedwrites
+ fn AuthenticatedSignedWrites(&self) -> bool {
+ self.authenticatedSignedWrites
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-reliablewrite
+ fn ReliableWrite(&self) -> bool {
+ self.reliableWrite
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-writableauxiliaries
+ fn WritableAuxiliaries(&self) -> bool {
+ self.writableAuxiliaries
+ }
+}
diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs
new file mode 100644
index 00000000000..a941f89fa7e
--- /dev/null
+++ b/components/script/dom/bluetoothdevice.rs
@@ -0,0 +1,125 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+use dom::bindings::codegen::Bindings::BluetoothDeviceBinding;
+use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::{BluetoothDeviceMethods, VendorIDSource};
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::{JS, Root, MutHeap};
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;
+use dom::bluetoothremotegattserver::BluetoothRemoteGATTServer;
+use util::str::DOMString;
+
+// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdevice
+#[dom_struct]
+pub struct BluetoothDevice {
+ reflector_: Reflector,
+ id: DOMString,
+ name: DOMString,
+ adData: MutHeap<JS<BluetoothAdvertisingData>>,
+ deviceClass: u32,
+ vendorIDSource: VendorIDSource,
+ vendorID: u32,
+ productID: u32,
+ productVersion: u32,
+ gatt: MutHeap<JS<BluetoothRemoteGATTServer>>,
+}
+
+impl BluetoothDevice {
+ pub fn new_inherited(id: DOMString,
+ name: DOMString,
+ adData: &BluetoothAdvertisingData,
+ deviceClass: u32,
+ vendorIDSource: VendorIDSource,
+ vendorID: u32,
+ productID: u32,
+ productVersion: u32,
+ gatt: &BluetoothRemoteGATTServer)
+ -> BluetoothDevice {
+ BluetoothDevice {
+ reflector_: Reflector::new(),
+ id: id,
+ name: name,
+ adData: MutHeap::new(adData),
+ deviceClass: deviceClass,
+ vendorIDSource: vendorIDSource,
+ vendorID: vendorID,
+ productID: productID,
+ productVersion: productVersion,
+ gatt: MutHeap::new(gatt),
+ }
+ }
+
+ pub fn new(global: GlobalRef,
+ id: DOMString,
+ name: DOMString,
+ adData: &BluetoothAdvertisingData,
+ deviceClass: u32,
+ vendorIDSource: VendorIDSource,
+ vendorID: u32,
+ productID: u32,
+ productVersion: u32,
+ gatt: &BluetoothRemoteGATTServer)
+ -> Root<BluetoothDevice> {
+ reflect_dom_object(box BluetoothDevice::new_inherited(id,
+ name,
+ adData,
+ deviceClass,
+ vendorIDSource,
+ vendorID,
+ productID,
+ productVersion,
+ gatt),
+ global,
+ BluetoothDeviceBinding::Wrap)
+ }
+}
+
+impl BluetoothDeviceMethods for BluetoothDevice {
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-id
+ fn Id(&self) -> DOMString {
+ self.id.clone()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-name
+ fn GetName(&self) -> Option<DOMString> {
+ Some(self.name.clone())
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-addata
+ fn AdData(&self) -> Root<BluetoothAdvertisingData> {
+ self.adData.get()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-deviceclass
+ fn GetDeviceClass(&self) -> Option<u32> {
+ Some(self.deviceClass)
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-vendoridsource
+ fn GetVendorIDSource(&self) -> Option<VendorIDSource> {
+ Some(self.vendorIDSource)
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-vendorid
+ fn GetVendorID(&self) -> Option<u32> {
+ Some(self.vendorID)
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-productid
+ fn GetProductID(&self) -> Option<u32> {
+ Some(self.productID)
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-productversion
+ fn GetProductVersion(&self) -> Option<u32> {
+ Some(self.productVersion)
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothdevice-gatt
+ fn Gatt(&self) -> Root<BluetoothRemoteGATTServer> {
+ self.gatt.get()
+ }
+}
diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs
new file mode 100644
index 00000000000..4b05b347242
--- /dev/null
+++ b/components/script/dom/bluetoothremotegattcharacteristic.rs
@@ -0,0 +1,87 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding;
+use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::
+ BluetoothRemoteGATTCharacteristicMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::{JS, MutHeap, Root};
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::bindings::str::ByteString;
+use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
+use dom::bluetoothremotegattdescriptor::BluetoothRemoteGATTDescriptor;
+use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
+use util::str::DOMString;
+
+// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacteristic
+#[dom_struct]
+pub struct BluetoothRemoteGATTCharacteristic {
+ reflector_: Reflector,
+ service: MutHeap<JS<BluetoothRemoteGATTService>>,
+ uuid: DOMString,
+ properties: MutHeap<JS<BluetoothCharacteristicProperties>>,
+ value: Option<ByteString>,
+}
+
+impl BluetoothRemoteGATTCharacteristic {
+ pub fn new_inherited(service: &BluetoothRemoteGATTService,
+ uuid: DOMString,
+ properties: &BluetoothCharacteristicProperties)
+ -> BluetoothRemoteGATTCharacteristic {
+ BluetoothRemoteGATTCharacteristic {
+ reflector_: Reflector::new(),
+ service: MutHeap::new(service),
+ uuid: uuid,
+ properties: MutHeap::new(properties),
+ value: None,
+ }
+ }
+
+ pub fn new(global: GlobalRef,
+ service: &BluetoothRemoteGATTService,
+ uuid: DOMString,
+ properties: &BluetoothCharacteristicProperties)
+ -> Root<BluetoothRemoteGATTCharacteristic> {
+ reflect_dom_object(box BluetoothRemoteGATTCharacteristic::new_inherited(service,
+ uuid,
+ properties),
+ global,
+ BluetoothRemoteGATTCharacteristicBinding::Wrap)
+ }
+}
+
+impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteristic {
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-properties
+ fn Properties(&self) -> Root<BluetoothCharacteristicProperties> {
+ self.properties.get()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-service
+ fn Service(&self) -> Root<BluetoothRemoteGATTService> {
+ self.service.get()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-uuid
+ fn Uuid(&self) -> DOMString {
+ self.uuid.clone()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptor
+ fn GetDescriptor(&self) -> Option<Root<BluetoothRemoteGATTDescriptor>> {
+ //UNIMPLEMENTED
+ None
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-value
+ fn GetValue(&self) -> Option<ByteString> {
+ self.value.clone()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue
+ fn ReadValue(&self) -> ByteString {
+ //UNIMPLEMENTED
+ ByteString::new(vec!())
+ }
+}
diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs
new file mode 100644
index 00000000000..5812a2ea832
--- /dev/null
+++ b/components/script/dom/bluetoothremotegattdescriptor.rs
@@ -0,0 +1,68 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding;
+use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding::BluetoothRemoteGATTDescriptorMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::{JS, MutHeap, Root};
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::bindings::str::ByteString;
+use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
+use util::str::DOMString;
+
+// http://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattdescriptor
+#[dom_struct]
+pub struct BluetoothRemoteGATTDescriptor {
+ reflector_: Reflector,
+ characteristic: MutHeap<JS<BluetoothRemoteGATTCharacteristic>>,
+ uuid: DOMString,
+ value: Option<ByteString>,
+}
+
+impl BluetoothRemoteGATTDescriptor {
+ pub fn new_inherited(characteristic: &BluetoothRemoteGATTCharacteristic,
+ uuid: DOMString)
+ -> BluetoothRemoteGATTDescriptor {
+ BluetoothRemoteGATTDescriptor {
+ reflector_: Reflector::new(),
+ characteristic: MutHeap::new(characteristic),
+ uuid: uuid,
+ value: None,
+ }
+ }
+
+ pub fn new(global: GlobalRef,
+ characteristic: &BluetoothRemoteGATTCharacteristic,
+ uuid: DOMString)
+ -> Root<BluetoothRemoteGATTDescriptor>{
+ reflect_dom_object(box BluetoothRemoteGATTDescriptor::new_inherited(characteristic,
+ uuid),
+ global,
+ BluetoothRemoteGATTDescriptorBinding::Wrap)
+ }
+}
+
+impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-characteristic
+ fn Characteristic(&self) -> Root<BluetoothRemoteGATTCharacteristic> {
+ self.characteristic.get()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-uuid
+ fn Uuid(&self) -> DOMString {
+ self.uuid.clone()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-value
+ fn GetValue(&self) -> Option<ByteString> {
+ self.value.clone()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
+ fn ReadValue(&self) -> ByteString {
+ //UNIMPLEMENTED
+ ByteString::new(vec!())
+ }
+}
diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs
new file mode 100644
index 00000000000..7441344fe2f
--- /dev/null
+++ b/components/script/dom/bluetoothremotegattserver.rs
@@ -0,0 +1,70 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
+use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::{JS, MutHeap, Root};
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::bluetoothdevice::BluetoothDevice;
+use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
+use std::cell::Cell;
+
+// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattserver
+#[dom_struct]
+pub struct BluetoothRemoteGATTServer {
+ reflector_: Reflector,
+ device: MutHeap<JS<BluetoothDevice>>,
+ connected: Cell<bool>,
+}
+
+impl BluetoothRemoteGATTServer {
+ pub fn new_inherited(device: &BluetoothDevice, is_connected: bool) -> BluetoothRemoteGATTServer {
+ BluetoothRemoteGATTServer {
+ reflector_: Reflector::new(),
+ device: MutHeap::new(device),
+ connected: Cell::new(is_connected),
+ }
+ }
+
+ pub fn new(global: GlobalRef, device: &BluetoothDevice, connected: bool) -> Root<BluetoothRemoteGATTServer> {
+ reflect_dom_object(box BluetoothRemoteGATTServer::new_inherited(
+ device,
+ connected),
+ global,
+ BluetoothRemoteGATTServerBinding::Wrap)
+ }
+}
+
+impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-device
+ fn Device(&self) -> Root<BluetoothDevice> {
+ self.device.get()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connected
+ fn Connected(&self) -> bool {
+ self.connected.get()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
+ fn Connect(&self) -> Root<BluetoothRemoteGATTServer> {
+ if !self.connected.get() {
+ self.connected.set(true);
+ }
+ Root::from_ref(self)
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-disconnect
+ fn Disconnect(&self) {
+ self.connected.set(false);
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservice
+ fn GetPrimaryService(&self) -> Option<Root<BluetoothRemoteGATTService>> {
+ //UNIMPLEMENTED
+ None
+ }
+}
diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs
new file mode 100644
index 00000000000..af2cd70ce7c
--- /dev/null
+++ b/components/script/dom/bluetoothremotegattservice.rs
@@ -0,0 +1,70 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
+use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::{JS, MutHeap, Root};
+use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::bluetoothdevice::BluetoothDevice;
+use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
+use util::str::DOMString;
+
+// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice
+#[dom_struct]
+pub struct BluetoothRemoteGATTService {
+ reflector_: Reflector,
+ device: MutHeap<JS<BluetoothDevice>>,
+ uuid: DOMString,
+ isPrimary: bool,
+}
+
+impl BluetoothRemoteGATTService {
+ pub fn new_inherited(device: &BluetoothDevice,
+ uuid: DOMString,
+ isPrimary: bool)
+ -> BluetoothRemoteGATTService {
+ BluetoothRemoteGATTService {
+ reflector_: Reflector::new(),
+ device: MutHeap::new(device),
+ uuid: uuid,
+ isPrimary: isPrimary,
+ }
+ }
+
+ pub fn new(global: GlobalRef,
+ device: &BluetoothDevice,
+ uuid: DOMString,
+ isPrimary: bool)
+ -> Root<BluetoothRemoteGATTService> {
+ reflect_dom_object(box BluetoothRemoteGATTService::new_inherited(device,
+ uuid,
+ isPrimary),
+ global,
+ BluetoothRemoteGATTServiceBinding::Wrap)
+ }
+}
+
+impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-device
+ fn Device(&self) -> Root<BluetoothDevice> {
+ self.device.get()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-isprimary
+ fn IsPrimary(&self) -> bool {
+ self.isPrimary
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-uuid
+ fn Uuid(&self) -> DOMString {
+ self.uuid.clone()
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-getcharacteristic
+ fn GetCharacteristic(&self) -> Option<Root<BluetoothRemoteGATTCharacteristic>> {
+ // UNIMPLEMENTED
+ None
+ }
+}
diff --git a/components/script/dom/bluetoothuuid.rs b/components/script/dom/bluetoothuuid.rs
new file mode 100644
index 00000000000..33aa6d944d5
--- /dev/null
+++ b/components/script/dom/bluetoothuuid.rs
@@ -0,0 +1,116 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
+use dom::bindings::error::Error::Syntax;
+use dom::bindings::error::Fallible;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::reflector::Reflector;
+use regex::Regex;
+use util::str::DOMString;
+
+pub type UUID = DOMString;
+
+// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothuuid
+ #[dom_struct]
+pub struct BluetoothUUID {
+ reflector_: Reflector,
+}
+
+const BLUETOOTH_ASSIGNED_SERVICES: &'static [(&'static str, u32)] = &[
+//TODO(zakorgy) create all the services
+//https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
+ ("org.bluetooth.service.alert_notification", 0x1811_u32),
+ ("org.bluetooth.service.automation_io", 0x1815_u32),
+ ("org.bluetooth.service.battery_service", 0x180f_u32)
+];
+
+const BLUETOOTH_ASSIGNED_CHARCTERISTICS: &'static [(&'static str, u32)] = &[
+//TODO(zakorgy) create all the characteristics
+//https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
+ ("org.bluetooth.characteristic.aerobic_heart_rate_lower_limit", 0x2a7e_u32),
+ ("org.bluetooth.characteristic.aerobic_heart_rate_upper_limit", 0x2a84_u32),
+ ("org.bluetooth.characteristic.battery_level", 0x2a19_u32)
+];
+
+const BLUETOOTH_ASSIGNED_DESCRIPTORS: &'static [(&'static str, u32)] = &[
+//TODO(zakorgy) create all the descriptors
+//https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
+ ("org.bluetooth.descriptor.gatt.characteristic_extended_properties", 0x2900_u32),
+ ("org.bluetooth.descriptor.gatt.characteristic_user_description", 0x2901_u32)
+];
+
+const BASE_UUID: &'static str = "-0000-1000-8000-00805f9b34fb";
+const SERVICE_PREFIX: &'static str = "org.bluetooth.service";
+const CHARACTERISTIC_PREFIX: &'static str = "org.bluetooth.characteristic";
+const DESCRIPTOR_PREFIX: &'static str = "org.bluetooth.descriptor";
+const VALID_UUID_REGEX: &'static str = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
+
+impl BluetoothUUID {
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-canonicaluuid
+ pub fn CanonicalUUID(_: GlobalRef, alias: u32) -> UUID {
+ DOMString::from(format!("{:08x}", &alias) + BASE_UUID)
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getservice
+ pub fn GetService(globalref: GlobalRef,
+ name: StringOrUnsignedLong)
+ -> Fallible<UUID> {
+ BluetoothUUID::resolve_uuid_name(globalref,
+ name,
+ BLUETOOTH_ASSIGNED_SERVICES,
+ DOMString::from(SERVICE_PREFIX))
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getcharacteristic
+ pub fn GetCharacteristic(globalref: GlobalRef,
+ name: StringOrUnsignedLong)
+ -> Fallible<UUID> {
+ BluetoothUUID::resolve_uuid_name(globalref,
+ name,
+ BLUETOOTH_ASSIGNED_CHARCTERISTICS,
+ DOMString::from(CHARACTERISTIC_PREFIX))
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getdescriptor
+ pub fn GetDescriptor(globalref: GlobalRef,
+ name: StringOrUnsignedLong)
+ -> Fallible<UUID> {
+ BluetoothUUID::resolve_uuid_name(globalref,
+ name,
+ BLUETOOTH_ASSIGNED_DESCRIPTORS,
+ DOMString::from(DESCRIPTOR_PREFIX))
+ }
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#resolveuuidname
+ pub fn resolve_uuid_name(globalref: GlobalRef,
+ name: StringOrUnsignedLong,
+ assigned_numbers_table: &'static [(&'static str, u32)],
+ prefix: DOMString)
+ -> Fallible<DOMString> {
+ match name {
+ // Step 1
+ StringOrUnsignedLong::UnsignedLong(unsigned32) =>{
+ Ok(BluetoothUUID::CanonicalUUID(globalref, unsigned32))
+ },
+ StringOrUnsignedLong::String(dstring) => {
+ // Step 2
+ let regex = Regex::new(VALID_UUID_REGEX).unwrap();
+ if regex.is_match(&*dstring) {
+ Ok(dstring)
+ } else {
+ // Step 3
+ let concatenated = format!("{}.{}", prefix, dstring);
+ let is_in_table = assigned_numbers_table.iter()
+ .find(|p| p.0 == concatenated);
+ match is_in_table {
+ Some(&(_, alias)) => Ok(BluetoothUUID::CanonicalUUID(globalref, alias)),
+ None => Err(Syntax),
+ }
+ }
+ },
+ }
+ }
+}
diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs
index 3656055feb0..15c57d04e60 100644
--- a/components/script/dom/mod.rs
+++ b/components/script/dom/mod.rs
@@ -218,6 +218,15 @@ mod create;
#[deny(missing_docs, non_snake_case)]
pub mod bindings;
pub mod blob;
+pub mod bluetooth;
+pub mod bluetoothadvertisingdata;
+pub mod bluetoothcharacteristicproperties;
+pub mod bluetoothdevice;
+pub mod bluetoothremotegattcharacteristic;
+pub mod bluetoothremotegattdescriptor;
+pub mod bluetoothremotegattserver;
+pub mod bluetoothremotegattservice;
+pub mod bluetoothuuid;
pub mod browsingcontext;
pub mod canvasgradient;
pub mod canvaspattern;
diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs
index 5fa0465d361..9803b6562b6 100644
--- a/components/script/dom/navigator.rs
+++ b/components/script/dom/navigator.rs
@@ -5,8 +5,9 @@
use dom::bindings::codegen::Bindings::NavigatorBinding;
use dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
use dom::bindings::global::GlobalRef;
-use dom::bindings::js::Root;
-use dom::bindings::reflector::{Reflector, reflect_dom_object};
+use dom::bindings::js::{JS, MutNullableHeap, Root};
+use dom::bindings::reflector::{Reflector, Reflectable, reflect_dom_object};
+use dom::bluetooth::Bluetooth;
use dom::navigatorinfo;
use dom::window::Window;
use util::str::DOMString;
@@ -14,12 +15,14 @@ use util::str::DOMString;
#[dom_struct]
pub struct Navigator {
reflector_: Reflector,
+ bluetooth: MutNullableHeap<JS<Bluetooth>>,
}
impl Navigator {
fn new_inherited() -> Navigator {
Navigator {
- reflector_: Reflector::new()
+ reflector_: Reflector::new(),
+ bluetooth: Default::default(),
}
}
@@ -65,4 +68,9 @@ impl NavigatorMethods for Navigator {
fn AppVersion(&self) -> DOMString {
navigatorinfo::AppVersion()
}
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-navigator-bluetooth
+ fn Bluetooth(&self) -> Root<Bluetooth> {
+ self.bluetooth.or_init(|| Bluetooth::new(self.global().r()))
+ }
}
diff --git a/components/script/dom/webidls/Bluetooth.webidl b/components/script/dom/webidls/Bluetooth.webidl
new file mode 100644
index 00000000000..3ff1c91efab
--- /dev/null
+++ b/components/script/dom/webidls/Bluetooth.webidl
@@ -0,0 +1,15 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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://webbluetoothcg.github.io/web-bluetooth/#bluetooth
+
+interface Bluetooth {
+ // Promise<BluetoothDevice> requestDevice(RequestDeviceOptions options);
+ BluetoothDevice? requestDevice(/*RequestDeviceOptions options*/);
+};
+
+// Bluetooth implements EventTarget;
+// Bluetooth implements CharacteristicEventHandlers;
+// Bluetooth implements ServiceEventHandlers;
diff --git a/components/script/dom/webidls/BluetoothAdvertisingData.webidl b/components/script/dom/webidls/BluetoothAdvertisingData.webidl
new file mode 100644
index 00000000000..914b57bfc7e
--- /dev/null
+++ b/components/script/dom/webidls/BluetoothAdvertisingData.webidl
@@ -0,0 +1,22 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingdata
+
+/*interface BluetoothManufacturerDataMap {
+ readonly maplike<unsigned short, DataView>;
+};
+
+interface BluetoothServiceDataMap {
+ readonly maplike<UUID, DataView>;
+};*/
+
+interface BluetoothAdvertisingData {
+ readonly attribute unsigned short? appearance;
+ readonly attribute byte? txPower;
+ readonly attribute byte? rssi;
+ // readonly attribute BluetoothManufacturerDataMap manufacturerData;
+ // readonly attribute BluetoothServiceDataMap serviceData;
+};
diff --git a/components/script/dom/webidls/BluetoothCharacteristicProperties.webidl b/components/script/dom/webidls/BluetoothCharacteristicProperties.webidl
new file mode 100644
index 00000000000..bd6366b1681
--- /dev/null
+++ b/components/script/dom/webidls/BluetoothCharacteristicProperties.webidl
@@ -0,0 +1,18 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties
+
+interface BluetoothCharacteristicProperties {
+ readonly attribute boolean broadcast;
+ readonly attribute boolean read;
+ readonly attribute boolean writeWithoutResponse;
+ readonly attribute boolean write;
+ readonly attribute boolean notify;
+ readonly attribute boolean indicate;
+ readonly attribute boolean authenticatedSignedWrites;
+ readonly attribute boolean reliableWrite;
+ readonly attribute boolean writableAuxiliaries;
+};
diff --git a/components/script/dom/webidls/BluetoothDevice.webidl b/components/script/dom/webidls/BluetoothDevice.webidl
new file mode 100644
index 00000000000..bb055c1c177
--- /dev/null
+++ b/components/script/dom/webidls/BluetoothDevice.webidl
@@ -0,0 +1,30 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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://webbluetoothcg.github.io/web-bluetooth/#bluetoothdevice
+
+// Allocation authorities for Vendor IDs:
+enum VendorIDSource {
+ "bluetooth",
+ "usb"
+};
+
+interface BluetoothDevice {
+ readonly attribute DOMString id;
+ readonly attribute DOMString? name;
+ readonly attribute BluetoothAdvertisingData adData;
+ readonly attribute unsigned long? deviceClass;
+ readonly attribute VendorIDSource? vendorIDSource;
+ readonly attribute unsigned long? vendorID;
+ readonly attribute unsigned long? productID;
+ readonly attribute unsigned long? productVersion;
+ readonly attribute BluetoothRemoteGATTServer gatt;
+ // readonly attribute FrozenArray[] uuids;
+};
+
+// BluetoothDevice implements EventTarget;
+// BluetoothDevice implements BluetoothDeviceEventHandlers;
+// BluetoothDevice implements CharacteristicEventHandlers;
+// BluetoothDevice implements ServiceEventHandlers;
diff --git a/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl b/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl
new file mode 100644
index 00000000000..411cd04baa7
--- /dev/null
+++ b/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl
@@ -0,0 +1,25 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacteristic
+
+interface BluetoothRemoteGATTCharacteristic {
+ readonly attribute BluetoothRemoteGATTService service;
+ readonly attribute DOMString uuid;
+ readonly attribute BluetoothCharacteristicProperties properties;
+ readonly attribute ByteString? value;
+ BluetoothRemoteGATTDescriptor? getDescriptor(/*BluetoothDescriptorUUID descriptor*/);
+ //Promise<BluetoothRemoteGATTDescriptor> getDescriptor(BluetoothDescriptorUUID descriptor);
+ //Promise<sequence<BluetoothRemoteGATTDescriptor>>
+ //getDescriptors(optional BluetoothDescriptorUUID descriptor);
+ //Promise<DataView> readValue();
+ ByteString readValue();
+ //Promise<void> writeValue(BufferSource value);
+ //Promise<void> startNotifications();
+ //Promise<void> stopNotifications();
+};
+
+//BluetootRemoteGATTCharacteristic implements EventTarget;
+//BluetootRemoteGATTCharacteristic implements CharacteristicEventHandlers;
diff --git a/components/script/dom/webidls/BluetoothRemoteGATTDescriptor.webidl b/components/script/dom/webidls/BluetoothRemoteGATTDescriptor.webidl
new file mode 100644
index 00000000000..eb5b056f211
--- /dev/null
+++ b/components/script/dom/webidls/BluetoothRemoteGATTDescriptor.webidl
@@ -0,0 +1,16 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+// http://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattdescriptor
+
+interface BluetoothRemoteGATTDescriptor {
+ readonly attribute BluetoothRemoteGATTCharacteristic characteristic;
+ readonly attribute DOMString uuid;
+ readonly attribute ByteString? value;
+
+ ByteString readValue();
+ //Promise<DataView> readValue();
+ //Promise<void> writeValue(BufferSource value);
+};
diff --git a/components/script/dom/webidls/BluetoothRemoteGATTServer.webidl b/components/script/dom/webidls/BluetoothRemoteGATTServer.webidl
new file mode 100644
index 00000000000..ebeb933bdb9
--- /dev/null
+++ b/components/script/dom/webidls/BluetoothRemoteGATTServer.webidl
@@ -0,0 +1,17 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattserver
+
+interface BluetoothRemoteGATTServer {
+ readonly attribute BluetoothDevice device;
+ readonly attribute boolean connected;
+ BluetoothRemoteGATTServer connect();
+ void disconnect();
+ BluetoothRemoteGATTService? getPrimaryService();
+ //Promise<BluetoothRemoteGATTService> getPrimaryService(BluetoothServiceUUID service);
+ //Promise<sequence<BluetoothRemoteGATTService>>getPrimaryServices(optional BluetoothServiceUUID service);
+ //Promise<BluetoothRemoteGATTServer> connect();
+};
diff --git a/components/script/dom/webidls/BluetoothRemoteGATTService.webidl b/components/script/dom/webidls/BluetoothRemoteGATTService.webidl
new file mode 100644
index 00000000000..a02af691a60
--- /dev/null
+++ b/components/script/dom/webidls/BluetoothRemoteGATTService.webidl
@@ -0,0 +1,18 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice
+
+interface BluetoothRemoteGATTService {
+ readonly attribute BluetoothDevice device;
+ readonly attribute DOMString uuid;
+ readonly attribute boolean isPrimary;
+ BluetoothRemoteGATTCharacteristic? getCharacteristic(/*DOMString characteristic*/);
+ //Promise<BluetoothRemoteGATTCharacteristic>getCharacteristic(BluetoothCharacteristicUUID characteristic);
+ //Promise<sequence<BluetoothRemoteGATTCharacteristic>>
+ //getCharacteristics(optional BluetoothCharacteristicUUID characteristic);
+ //Promise<BluetoothRemoteGATTService>getIncludedService(BluetoothServiceUUID service);
+ //Promise<sequence<BluetoothRemoteGATTService>>getIncludedServices(optional BluetoothServiceUUID service);
+};
diff --git a/components/script/dom/webidls/BluetoothUUID.webidl b/components/script/dom/webidls/BluetoothUUID.webidl
new file mode 100644
index 00000000000..497be0a0fbc
--- /dev/null
+++ b/components/script/dom/webidls/BluetoothUUID.webidl
@@ -0,0 +1,21 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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://webbluetoothcg.github.io/web-bluetooth/#bluetoothuuid
+
+interface BluetoothUUID {
+ [Throws]
+ static UUID getService(BluetoothServiceUUID name);
+ [Throws]
+ static UUID getCharacteristic(BluetoothCharacteristicUUID name);
+ [Throws]
+ static UUID getDescriptor(BluetoothDescriptorUUID name);
+ static UUID canonicalUUID([EnforceRange] unsigned long alias);
+};
+
+typedef DOMString UUID;
+typedef (DOMString or unsigned long) BluetoothServiceUUID;
+typedef (DOMString or unsigned long) BluetoothCharacteristicUUID;
+typedef (DOMString or unsigned long) BluetoothDescriptorUUID;
diff --git a/components/script/dom/webidls/Navigator.webidl b/components/script/dom/webidls/Navigator.webidl
index 869eaab9deb..8a7a9ef914e 100644
--- a/components/script/dom/webidls/Navigator.webidl
+++ b/components/script/dom/webidls/Navigator.webidl
@@ -8,6 +8,7 @@ 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;
@@ -25,3 +26,8 @@ interface NavigatorID {
boolean taintEnabled(); // constant false
readonly attribute DOMString userAgent;
};
+
+[NoInterfaceObject]
+interface NavigatorBluetooth {
+ readonly attribute Bluetooth bluetooth;
+};
diff --git a/components/script/lib.rs b/components/script/lib.rs
index 93ba1dba8a4..1ef6668d9bd 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -61,6 +61,7 @@ extern crate phf;
extern crate profile_traits;
extern crate rand;
extern crate ref_slice;
+extern crate regex;
extern crate rustc_serialize;
extern crate script_traits;
extern crate selectors;
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 4e1725446d6..eeabb918898 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -190,7 +190,7 @@ name = "caseless"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -548,7 +548,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -825,7 +825,7 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1503,7 +1503,7 @@ dependencies = [
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"task_info 0.0.1",
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
@@ -1581,18 +1581,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "regex"
-version = "0.1.51"
+version = "0.1.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
-version = "0.2.3"
+version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -1651,6 +1651,7 @@ dependencies = [
"profile_traits 0.0.1",
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
"ref_slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"script_traits 0.0.1",
"selectors 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2214,7 +2215,7 @@ source = "git+https://github.com/jgraham/webdriver-rust.git#9dffcbe409af052788b7
dependencies = [
"hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2230,7 +2231,7 @@ dependencies = [
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"plugins 0.0.1",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index e7a33c0a55a..889f7b15a79 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -177,7 +177,7 @@ name = "caseless"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -487,7 +487,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -755,7 +755,7 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1391,7 +1391,7 @@ dependencies = [
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"task_info 0.0.1",
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
@@ -1467,18 +1467,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "regex"
-version = "0.1.51"
+version = "0.1.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
-version = "0.2.3"
+version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -1537,6 +1537,7 @@ dependencies = [
"profile_traits 0.0.1",
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
"ref_slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"script_traits 0.0.1",
"selectors 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2100,7 +2101,7 @@ source = "git+https://github.com/jgraham/webdriver-rust.git#9dffcbe409af052788b7
dependencies = [
"hyper 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2116,7 +2117,7 @@ dependencies = [
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"plugins 0.0.1",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock
index 43cb93a65ac..fef7f6d1754 100644
--- a/ports/gonk/Cargo.lock
+++ b/ports/gonk/Cargo.lock
@@ -169,7 +169,7 @@ name = "caseless"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -479,7 +479,7 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -736,7 +736,7 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1372,7 +1372,7 @@ dependencies = [
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
- "regex 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"task_info 0.0.1",
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
@@ -1448,18 +1448,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "regex"
-version = "0.1.51"
+version = "0.1.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
-version = "0.2.3"
+version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -1518,6 +1518,7 @@ dependencies = [
"profile_traits 0.0.1",
"rand 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
"ref_slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.55 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"script_traits 0.0.1",
"selectors 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/python/tidy.py b/python/tidy.py
index 35b4f230dbb..7989224a50a 100644
--- a/python/tidy.py
+++ b/python/tidy.py
@@ -463,6 +463,7 @@ def check_webidl_spec(file_name, contents):
"//xhr.spec.whatwg.org",
"//w3c.github.io",
"//heycam.github.io/webidl",
+ "//webbluetoothcg.github.io/web-bluetooth/",
# Not a URL
"// This interface is entirely internal to Servo, and should not be" +
" accessible to\n// web pages."
diff --git a/tests/wpt/mozilla/tests/mozilla/interfaces.html b/tests/wpt/mozilla/tests/mozilla/interfaces.html
index 48896836f0b..eaa0bdadcd1 100644
--- a/tests/wpt/mozilla/tests/mozilla/interfaces.html
+++ b/tests/wpt/mozilla/tests/mozilla/interfaces.html
@@ -73,6 +73,15 @@ var ecmaGlobals = [
var interfaceNamesInGlobalScope = [
"Attr",
"Blob",
+ "Bluetooth",
+ "BluetoothAdvertisingData",
+ "BluetoothCharacteristicProperties",
+ "BluetoothDevice",
+ "BluetoothRemoteGATTCharacteristic",
+ "BluetoothRemoteGATTDescriptor",
+ "BluetoothRemoteGATTServer",
+ "BluetoothRemoteGATTService",
+ "BluetoothUUID",
"CanvasGradient",
"CanvasRenderingContext2D",
"CanvasPattern",