aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bindings/callback.rs14
-rw-r--r--components/script/dom/bindings/error.rs3
-rw-r--r--components/script/dom/bluetoothremotegattcharacteristic.rs17
-rw-r--r--components/script/dom/htmldetailselement.rs2
-rw-r--r--components/script/dom/htmlformelement.rs3
-rw-r--r--components/script/dom/htmlimageelement.rs2
-rw-r--r--components/script/dom/htmlmediaelement.rs8
-rw-r--r--components/script/dom/storage.rs10
-rw-r--r--components/script/dom/window.rs5
9 files changed, 39 insertions, 25 deletions
diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs
index cc1266d27ab..c34598a26be 100644
--- a/components/script/dom/bindings/callback.rs
+++ b/components/script/dom/bindings/callback.rs
@@ -4,15 +4,14 @@
//! Base classes to work with IDL callbacks.
-use dom::bindings::error::{Error, Fallible};
+use dom::bindings::error::{Error, Fallible, report_pending_exception};
use dom::bindings::global::global_root_from_object;
use dom::bindings::reflector::Reflectable;
use js::jsapi::GetGlobalForObjectCrossCompartment;
-use js::jsapi::JSAutoCompartment;
+use js::jsapi::JS_GetProperty;
use js::jsapi::{Heap, MutableHandleObject, RootedObject};
use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject};
use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment};
-use js::jsapi::{JS_GetProperty, JS_IsExceptionPending, JS_ReportPendingException};
use js::jsval::{JSVal, UndefinedValue};
use js::rust::RootedGuard;
use std::default::Default;
@@ -189,13 +188,8 @@ impl<'a> Drop for CallSetup<'a> {
fn drop(&mut self) {
unsafe {
JS_LeaveCompartment(self.cx, self.old_compartment);
- }
- let need_to_deal_with_exception = self.handling == ExceptionHandling::Report &&
- unsafe { JS_IsExceptionPending(self.cx) };
- if need_to_deal_with_exception {
- unsafe {
- let _ac = JSAutoCompartment::new(self.cx, *self.exception_compartment);
- JS_ReportPendingException(self.cx);
+ if self.handling == ExceptionHandling::Report {
+ report_pending_exception(self.cx, *self.exception_compartment);
}
}
}
diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs
index 161e477a85a..d0074335c23 100644
--- a/components/script/dom/bindings/error.rs
+++ b/components/script/dom/bindings/error.rs
@@ -57,6 +57,8 @@ pub enum Error {
QuotaExceeded,
/// TypeMismatchError DOMException
TypeMismatch,
+ /// InvalidModificationError DOMException
+ InvalidModification,
/// TypeError JavaScript Error
Type(String),
@@ -97,6 +99,7 @@ pub unsafe fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef, result:
Error::NoModificationAllowed => DOMErrorName::NoModificationAllowedError,
Error::QuotaExceeded => DOMErrorName::QuotaExceededError,
Error::TypeMismatch => DOMErrorName::TypeMismatchError,
+ Error::InvalidModification => DOMErrorName::InvalidModificationError,
Error::Type(message) => {
assert!(!JS_IsExceptionPending(cx));
throw_type_error(cx, &message);
diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs
index 2b3443f8a40..ebdd59ca689 100644
--- a/components/script/dom/bluetoothremotegattcharacteristic.rs
+++ b/components/script/dom/bluetoothremotegattcharacteristic.rs
@@ -4,13 +4,15 @@
use bluetooth_blacklist::{Blacklist, uuid_is_blacklisted};
use dom::bindings::cell::DOMRefCell;
+use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
+ BluetoothCharacteristicPropertiesMethods;
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::
BluetoothRemoteGATTCharacteristicMethods;
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, NotSupported, Security, Type};
use dom::bindings::error::{Fallible, ErrorResult};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, MutHeap, Root};
@@ -23,6 +25,10 @@ use dom::bluetoothuuid::{BluetoothDescriptorUUID, BluetoothUUID};
use ipc_channel::ipc::{self, IpcSender};
use net_traits::bluetooth_thread::BluetoothMethodMsg;
+// Maximum length of an attribute value.
+// https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=286439 (Vol. 3, page 2169)
+const MAXIMUM_ATTRIBUTE_LENGTH: usize = 512;
+
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacteristic
#[dom_struct]
pub struct BluetoothRemoteGATTCharacteristic {
@@ -160,6 +166,9 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
if !self.Service().Device().Gatt().Connected() {
return Err(Network)
}
+ if !self.Properties().Read() {
+ return Err(NotSupported)
+ }
self.get_bluetooth_thread().send(
BluetoothMethodMsg::ReadValue(self.get_instance_id(), sender)).unwrap();
let result = receiver.recv().unwrap();
@@ -180,6 +189,12 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
if uuid_is_blacklisted(self.uuid.as_ref(), Blacklist::Writes) {
return Err(Security)
}
+ if value.len() > MAXIMUM_ATTRIBUTE_LENGTH {
+ return Err(InvalidModification)
+ }
+ if !self.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();
diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs
index d63e15178aa..07c85ed6e2e 100644
--- a/components/script/dom/htmldetailselement.rs
+++ b/components/script/dom/htmldetailselement.rs
@@ -79,7 +79,7 @@ impl VirtualMethods for HTMLDetailsElement {
element: details,
toggle_number: counter
};
- let _ = task_source.queue(DOMManipulationTask::FireToggleEvent(runnable));
+ let _ = task_source.queue(DOMManipulationTask::Runnable(runnable));
}
}
}
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index b31d33d5685..90baba4ebb1 100644
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -484,8 +484,7 @@ impl HTMLFormElement {
};
// Step 3
- window.dom_manipulation_task_source().queue(
- DOMManipulationTask::PlannedNavigation(nav)).unwrap();
+ window.dom_manipulation_task_source().queue(DOMManipulationTask::Runnable(nav)).unwrap();
}
/// Interactively validate the constraints of form elements
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index 2b61a800a1a..27152ca93f4 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -183,7 +183,7 @@ impl HTMLImageElement {
src: src.into(),
});
let task = window.dom_manipulation_task_source();
- let _ = task.queue(DOMManipulationTask::Miscellaneous(runnable));
+ let _ = task.queue(DOMManipulationTask::Runnable(runnable));
}
}
}
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 49d42c31f1a..7cfe19ba789 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -242,7 +242,7 @@ impl HTMLMediaElement {
elem: Trusted::new(self),
};
let win = window_from_node(self);
- let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::MediaTask(box task));
+ let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::Runnable(box task));
}
// https://html.spec.whatwg.org/multipage/#internal-pause-steps step 2.2
@@ -266,13 +266,13 @@ impl HTMLMediaElement {
elem: Trusted::new(self),
};
let win = window_from_node(self);
- let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::MediaTask(box task));
+ let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::Runnable(box task));
}
fn queue_fire_simple_event(&self, type_: &'static str) {
let win = window_from_node(self);
let task = FireSimpleEventTask::new(self, type_);
- let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::MediaTask(box task));
+ let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::Runnable(box task));
}
fn fire_simple_event(&self, type_: &str) {
@@ -497,7 +497,7 @@ impl HTMLMediaElement {
fn queue_dedicated_media_source_failure_steps(&self) {
let _ = window_from_node(self).dom_manipulation_task_source().queue(
- DOMManipulationTask::MediaTask(box DedicatedMediaSourceFailureTask::new(self)));
+ DOMManipulationTask::Runnable(box DedicatedMediaSourceFailureTask::new(self)));
}
// https://html.spec.whatwg.org/multipage/#dedicated-media-source-failure-steps
diff --git a/components/script/dom/storage.rs b/components/script/dom/storage.rs
index 03747ed5ab6..d927c5ba213 100644
--- a/components/script/dom/storage.rs
+++ b/components/script/dom/storage.rs
@@ -17,7 +17,7 @@ use dom::urlhelper::UrlHelper;
use ipc_channel::ipc::{self, IpcSender};
use net_traits::IpcSend;
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
-use script_thread::{MainThreadRunnable, ScriptThread};
+use script_thread::{Runnable, ScriptThread};
use task_source::TaskSource;
use task_source::dom_manipulation::DOMManipulationTask;
use url::Url;
@@ -161,7 +161,7 @@ impl Storage {
let global_ref = global_root.r();
let task_source = global_ref.as_window().dom_manipulation_task_source();
let trusted_storage = Trusted::new(self);
- task_source.queue(DOMManipulationTask::SendStorageNotification(
+ task_source.queue(DOMManipulationTask::Runnable(
box StorageEventRunnable::new(trusted_storage, key, old_value, new_value))).unwrap();
}
}
@@ -180,8 +180,10 @@ impl StorageEventRunnable {
}
}
-impl MainThreadRunnable for StorageEventRunnable {
- fn handler(self: Box<StorageEventRunnable>, script_thread: &ScriptThread) {
+impl Runnable for StorageEventRunnable {
+ fn name(&self) -> &'static str { "StorageEventRunnable" }
+
+ fn main_thread_handler(self: Box<StorageEventRunnable>, script_thread: &ScriptThread) {
let this = *self;
let storage_root = this.element.root();
let storage = storage_root.r();
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index a098edcb43c..34ac683e233 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -96,8 +96,8 @@ use timers::{IsInterval, OneshotTimerCallback, OneshotTimerHandle, OneshotTimers
use tinyfiledialogs::{self, MessageBoxIcon};
use url::Url;
use util::geometry::{self, MAX_RECT};
+use util::opts;
use util::prefs::PREFS;
-use util::{breakpoint, opts};
use webdriver_handlers::jsval_to_webdriver;
/// Current state of the window object
@@ -669,8 +669,9 @@ impl WindowMethods for Window {
}
}
+ #[allow(unsafe_code)]
fn Trap(&self) {
- breakpoint();
+ unsafe { ::std::intrinsics::breakpoint() }
}
#[allow(unsafe_code)]