diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index 0fae7548ede..16a2bde68f5 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -87,6 +87,9 @@ impl BluetoothRemoteGATTCharacteristic { if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) } + if !self.Service().Device().Gatt().Connected() { + return Err(Network) + } let (sender, receiver) = ipc::channel().unwrap(); self.get_bluetooth_thread().send( BluetoothMethodMsg::GetDescriptor(self.get_instance_id(), uuid, sender)).unwrap(); @@ -117,6 +120,9 @@ impl BluetoothRemoteGATTCharacteristic { } } }; + if !self.Service().Device().Gatt().Connected() { + return Err(Network) + } let (sender, receiver) = ipc::channel().unwrap(); self.get_bluetooth_thread().send( BluetoothMethodMsg::GetDescriptors(self.get_instance_id(), uuid, sender)).unwrap(); diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs index 5e589fe07af..3aafc788710 100644 --- a/components/script/dom/bluetoothremotegattserver.rs +++ b/components/script/dom/bluetoothremotegattserver.rs @@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMet use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use dom::bindings::error::{ErrorResult, Fallible}; -use dom::bindings::error::Error::{self, Security}; +use dom::bindings::error::Error::{self, Network, Security}; use dom::bindings::js::{JS, MutHeap, Root}; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; @@ -72,6 +72,9 @@ impl BluetoothRemoteGATTServer { if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) } + if !self.Device().Gatt().Connected() { + return Err(Network) + } let (sender, receiver) = ipc::channel().unwrap(); self.get_bluetooth_thread().send( BluetoothMethodMsg::GetPrimaryService(String::from(self.Device().Id()), uuid, sender)).unwrap(); @@ -103,6 +106,9 @@ impl BluetoothRemoteGATTServer { } } }; + if !self.Device().Gatt().Connected() { + return Err(Network) + } let (sender, receiver) = ipc::channel().unwrap(); self.get_bluetooth_thread().send( BluetoothMethodMsg::GetPrimaryServices(String::from(self.Device().Id()), uuid, sender)).unwrap(); diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs index a4fc78c8d93..a8c8265c3fd 100644 --- a/components/script/dom/bluetoothremotegattservice.rs +++ b/components/script/dom/bluetoothremotegattservice.rs @@ -4,9 +4,11 @@ use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted}; use bluetooth_traits::BluetoothMethodMsg; +use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; +use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; -use dom::bindings::error::Error::{self, Security}; +use dom::bindings::error::Error::{self, Network, Security}; use dom::bindings::error::Fallible; use dom::bindings::js::{JS, MutHeap, Root}; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; @@ -76,6 +78,9 @@ impl BluetoothRemoteGATTService { if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) } + if !self.Device().Gatt().Connected() { + return Err(Network) + } let (sender, receiver) = ipc::channel().unwrap(); self.get_bluetooth_thread().send( BluetoothMethodMsg::GetCharacteristic(self.get_instance_id(), uuid, sender)).unwrap(); @@ -118,6 +123,9 @@ impl BluetoothRemoteGATTService { } } }; + if !self.Device().Gatt().Connected() { + return Err(Network) + } let mut characteristics = vec!(); let (sender, receiver) = ipc::channel().unwrap(); self.get_bluetooth_thread().send( @@ -159,6 +167,9 @@ impl BluetoothRemoteGATTService { if uuid_is_blacklisted(uuid.as_ref(), Blacklist::All) { return Err(Security) } + if !self.Device().Gatt().Connected() { + return Err(Network) + } let (sender, receiver) = ipc::channel().unwrap(); self.get_bluetooth_thread().send( BluetoothMethodMsg::GetIncludedService(self.get_instance_id(), @@ -192,6 +203,9 @@ impl BluetoothRemoteGATTService { } } }; + if !self.Device().Gatt().Connected() { + return Err(Network) + } let (sender, receiver) = ipc::channel().unwrap(); self.get_bluetooth_thread().send( BluetoothMethodMsg::GetIncludedServices(self.get_instance_id(), diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getCharacteristic/disconnect-called-before.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getCharacteristic/disconnect-called-before.html.ini deleted file mode 100644 index 5530d529555..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getCharacteristic/disconnect-called-before.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnect-called-before.html] - type: testharness - [disconnect() called before getCharacteristic. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getCharacteristics/disconnect-called-before-with-uuid.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getCharacteristics/disconnect-called-before-with-uuid.html.ini deleted file mode 100644 index 964190d4d88..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getCharacteristics/disconnect-called-before-with-uuid.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnect-called-before-with-uuid.html] - type: testharness - [disconnect() called before getCharacteristics. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getCharacteristics/disconnect-called-before.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getCharacteristics/disconnect-called-before.html.ini deleted file mode 100644 index 5999c62bbda..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getCharacteristics/disconnect-called-before.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnect-called-before.html] - type: testharness - [disconnect() called before getCharacteristics. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getDescriptor/disconnect-called-before.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getDescriptor/disconnect-called-before.html.ini deleted file mode 100644 index 6754770f361..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getDescriptor/disconnect-called-before.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnect-called-before.html] - type: testharness - [disconnect() called before getDescriptor. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getDescriptors/disconnect-called-before-with-uuid.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getDescriptors/disconnect-called-before-with-uuid.html.ini deleted file mode 100644 index 2ef92759456..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getDescriptors/disconnect-called-before-with-uuid.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnect-called-before-with-uuid.html] - type: testharness - [disconnect() called before getDescriptors. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getDescriptors/disconnect-called-before.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getDescriptors/disconnect-called-before.html.ini deleted file mode 100644 index 85d9bc4fba0..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getDescriptors/disconnect-called-before.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnect-called-before.html] - type: testharness - [disconnect() called before getDescriptors. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryService/disconnect-called-before.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryService/disconnect-called-before.html.ini deleted file mode 100644 index 7bffa89c3f4..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryService/disconnect-called-before.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnect-called-before.html] - type: testharness - [disconnect() called before getPrimaryService. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryService/disconnected-device.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryService/disconnected-device.html.ini deleted file mode 100644 index e8641d4018e..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryService/disconnected-device.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnected-device.html] - type: testharness - [getPrimaryService called before connecting. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnect-called-before-with-uuid.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnect-called-before-with-uuid.html.ini deleted file mode 100644 index 70c8240fe4e..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnect-called-before-with-uuid.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnect-called-before-with-uuid.html] - type: testharness - [disconnect() called before getPrimaryServices. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnect-called-before.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnect-called-before.html.ini deleted file mode 100644 index fd52ad11a12..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnect-called-before.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnect-called-before.html] - type: testharness - [disconnect() called before getPrimaryServices. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnected-device-with-uuid.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnected-device-with-uuid.html.ini deleted file mode 100644 index 8ce91b03bea..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnected-device-with-uuid.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnected-device-with-uuid.html] - type: testharness - [getPrimaryServices called before connecting. Reject with NetworkError.] - expected: FAIL diff --git a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnected-device.html.ini b/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnected-device.html.ini deleted file mode 100644 index 2916ee4842e..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/bluetooth/getPrimaryServices/disconnected-device.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[disconnected-device.html] - type: testharness - [getPrimaryServices called before connecting. Reject with NetworkError.] - expected: FAIL