aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bluetooth.rs14
-rw-r--r--components/script/dom/bluetoothremotegattcharacteristic.rs12
-rw-r--r--components/script/dom/bluetoothremotegattdescriptor.rs11
-rw-r--r--components/script/dom/webidls/Bluetooth.webidl6
-rw-r--r--components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl3
-rw-r--r--components/script/dom/webidls/BluetoothRemoteGATTDescriptor.webidl3
6 files changed, 32 insertions, 17 deletions
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs
index e0dd0f00e10..b980562c46d 100644
--- a/components/script/dom/bluetooth.rs
+++ b/components/script/dom/bluetooth.rs
@@ -14,7 +14,7 @@ use dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::Bluetoot
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerBinding::
BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::Bindings::PermissionStatusBinding::{PermissionName, PermissionState};
-use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
+use dom::bindings::codegen::UnionTypes::{ArrayBufferViewOrArrayBuffer, StringOrUnsignedLong};
use dom::bindings::error::Error::{self, Network, Security, Type};
use dom::bindings::error::Fallible;
use dom::bindings::refcounted::{Trusted, TrustedPromise};
@@ -442,12 +442,20 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdatafilterinit-canonicalizing
fn canonicalize_bluetooth_data_filter_init(bdfi: &BluetoothDataFilterInit) -> Fallible<(Vec<u8>, Vec<u8>)> {
// Step 1.
- let data_prefix = bdfi.dataPrefix.clone().unwrap_or(vec![]);
+ let data_prefix = match bdfi.dataPrefix {
+ Some(ArrayBufferViewOrArrayBuffer::ArrayBufferView(ref avb)) => avb.to_vec(),
+ Some(ArrayBufferViewOrArrayBuffer::ArrayBuffer(ref ab)) => ab.to_vec(),
+ None => vec![]
+ };
// Step 2.
// If no mask present, mask will be a sequence of 0xFF bytes the same length as dataPrefix.
// Masking dataPrefix with this, leaves dataPrefix untouched.
- let mask = bdfi.mask.clone().unwrap_or(vec![0xFF; data_prefix.len()]);
+ let mask = match bdfi.mask {
+ Some(ArrayBufferViewOrArrayBuffer::ArrayBufferView(ref avb)) => avb.to_vec(),
+ Some(ArrayBufferViewOrArrayBuffer::ArrayBuffer(ref ab)) => ab.to_vec(),
+ None => vec![0xFF; data_prefix.len()]
+ };
// Step 3.
if mask.len() != data_prefix.len() {
diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs
index 20037c9920c..8034623ff5c 100644
--- a/components/script/dom/bluetoothremotegattcharacteristic.rs
+++ b/components/script/dom/bluetoothremotegattcharacteristic.rs
@@ -12,6 +12,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::
BluetoothRemoteGATTCharacteristicMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
+use dom::bindings::codegen::UnionTypes::ArrayBufferViewOrArrayBuffer;
use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, reflect_dom_object};
@@ -155,7 +156,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
#[allow(unrooted_must_root)]
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-writevalue
- fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> {
+ fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer) -> Rc<Promise> {
let p = Promise::new(&self.global());
// Step 1.
@@ -165,7 +166,12 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
}
// Step 2 - 3.
- if value.len() > MAXIMUM_ATTRIBUTE_LENGTH {
+ let vec = match value {
+ ArrayBufferViewOrArrayBuffer::ArrayBufferView(avb) => avb.to_vec(),
+ ArrayBufferViewOrArrayBuffer::ArrayBuffer(ab) => ab.to_vec(),
+ };
+
+ if vec.len() > MAXIMUM_ATTRIBUTE_LENGTH {
p.reject_error(InvalidModification);
return p;
}
@@ -190,7 +196,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
// in writeValue function and in handle_response function.
let sender = response_async(&p, self);
self.get_bluetooth_thread().send(
- BluetoothRequest::WriteValue(self.get_instance_id(), value, sender)).unwrap();
+ BluetoothRequest::WriteValue(self.get_instance_id(), vec, sender)).unwrap();
return p;
}
diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs
index 94023d6ffa0..493550ee91b 100644
--- a/components/script/dom/bluetoothremotegattdescriptor.rs
+++ b/components/script/dom/bluetoothremotegattdescriptor.rs
@@ -11,6 +11,7 @@ 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::codegen::UnionTypes::ArrayBufferViewOrArrayBuffer;
use dom::bindings::error::Error::{self, InvalidModification, Network, Security};
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{Dom, DomRoot};
@@ -114,7 +115,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
#[allow(unrooted_must_root)]
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue
- fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> {
+ fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer) -> Rc<Promise> {
let p = Promise::new(&self.global());
// Step 1.
@@ -124,7 +125,11 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
}
// Step 2 - 3.
- if value.len() > MAXIMUM_ATTRIBUTE_LENGTH {
+ let vec = match value {
+ ArrayBufferViewOrArrayBuffer::ArrayBufferView(avb) => avb.to_vec(),
+ ArrayBufferViewOrArrayBuffer::ArrayBuffer(ab) => ab.to_vec(),
+ };
+ if vec.len() > MAXIMUM_ATTRIBUTE_LENGTH {
p.reject_error(InvalidModification);
return p;
}
@@ -140,7 +145,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
// in writeValue function and in handle_response function.
let sender = response_async(&p, self);
self.get_bluetooth_thread().send(
- BluetoothRequest::WriteValue(self.get_instance_id(), value, sender)).unwrap();
+ BluetoothRequest::WriteValue(self.get_instance_id(), vec, sender)).unwrap();
return p;
}
}
diff --git a/components/script/dom/webidls/Bluetooth.webidl b/components/script/dom/webidls/Bluetooth.webidl
index 7fc4c7392ad..f891b5f38a5 100644
--- a/components/script/dom/webidls/Bluetooth.webidl
+++ b/components/script/dom/webidls/Bluetooth.webidl
@@ -5,10 +5,8 @@
// https://webbluetoothcg.github.io/web-bluetooth/#bluetooth
dictionary BluetoothDataFilterInit {
- // BufferSource dataPrefix;
- sequence<octet> dataPrefix;
- // BufferSource mask;
- sequence<octet> mask;
+ BufferSource dataPrefix;
+ BufferSource mask;
};
dictionary BluetoothLEScanFilterInit {
diff --git a/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl b/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl
index 3e086fc21ca..07cedd97421 100644
--- a/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl
+++ b/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl
@@ -16,8 +16,7 @@ interface BluetoothRemoteGATTCharacteristic : EventTarget {
getDescriptors(optional BluetoothDescriptorUUID descriptor);
Promise<ByteString> readValue();
//Promise<DataView> readValue();
- Promise<void> writeValue(sequence<octet> value);
- //Promise<void> writeValue(BufferSource value);
+ Promise<void> writeValue(BufferSource value);
Promise<BluetoothRemoteGATTCharacteristic> startNotifications();
Promise<BluetoothRemoteGATTCharacteristic> stopNotifications();
};
diff --git a/components/script/dom/webidls/BluetoothRemoteGATTDescriptor.webidl b/components/script/dom/webidls/BluetoothRemoteGATTDescriptor.webidl
index a202975013c..243b86fe155 100644
--- a/components/script/dom/webidls/BluetoothRemoteGATTDescriptor.webidl
+++ b/components/script/dom/webidls/BluetoothRemoteGATTDescriptor.webidl
@@ -12,6 +12,5 @@ interface BluetoothRemoteGATTDescriptor {
readonly attribute ByteString? value;
Promise<ByteString> readValue();
//Promise<DataView> readValue();
- Promise<void> writeValue(sequence<octet> value);
- //Promise<void> writeValue(BufferSource value);
+ Promise<void> writeValue(BufferSource value);
};