aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bluetoothremotegattdescriptor.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-07-07 18:15:38 -0700
committerGitHub <noreply@github.com>2016-07-07 18:15:38 -0700
commita8fd13bac33bc55f0815883cce687def1cb69b01 (patch)
tree9b0939d1dd492016e4bc176a7e0eb6f44b3c5164 /components/script/dom/bluetoothremotegattdescriptor.rs
parent0eed0e0b1e5ab2fc69ce64d5a0dd8c21d770092b (diff)
parent2ab4511de81cedfa234d54b1c2946cd6ccaca4f7 (diff)
downloadservo-a8fd13bac33bc55f0815883cce687def1cb69b01.tar.gz
servo-a8fd13bac33bc55f0815883cce687def1cb69b01.zip
Auto merge of #12309 - szeged:descriptor-functions, r=jdm
Add missing steps to descriptors writeValue function <!-- Please describe your changes on the following line: --> Add two missing steps to characteristic's writeValue function. https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue (Step 4 and 5) <!-- 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 do not require tests, because there is no Web Bluetooth test API implementation yet. <!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12309) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bluetoothremotegattdescriptor.rs')
-rw-r--r--components/script/dom/bluetoothremotegattdescriptor.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs
index d2c1de65cb3..035233b01f7 100644
--- a/components/script/dom/bluetoothremotegattdescriptor.rs
+++ b/components/script/dom/bluetoothremotegattdescriptor.rs
@@ -11,13 +11,13 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding::BluetoothRemoteGATTDescriptorMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
-use dom::bindings::error::Error::{Network, Security, Type};
+use dom::bindings::error::Error::{InvalidModification, Network, Security, Type};
use dom::bindings::error::{Fallible, ErrorResult};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, MutHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::str::{ByteString, DOMString};
-use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
+use dom::bluetoothremotegattcharacteristic::{BluetoothRemoteGATTCharacteristic, MAXIMUM_ATTRIBUTE_LENGTH};
use ipc_channel::ipc::{self, IpcSender};
use net_traits::bluetooth_thread::BluetoothMethodMsg;
@@ -113,6 +113,12 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
if uuid_is_blacklisted(self.uuid.as_ref(), Blacklist::Writes) {
return Err(Security)
}
+ if value.len() > MAXIMUM_ATTRIBUTE_LENGTH {
+ return Err(InvalidModification)
+ }
+ if !self.Characteristic().Service().Device().Gatt().Connected() {
+ return Err(Network)
+ }
let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(
BluetoothMethodMsg::WriteValue(self.get_instance_id(), value, sender)).unwrap();