diff options
19 files changed, 81 insertions, 74 deletions
diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index 4e4ae77213b..35f6e903103 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -113,11 +113,14 @@ impl FontHandle { let pair_data_start = subtable_start + FORMAT_0_HEADER_LEN; result.pair_data_range = pair_data_start..end; + if result.pair_data_range.len() != n_pairs * KERN_PAIR_LEN { + debug!("Bad data in kern header. Disable fast path."); + return None; + } + let pt_per_font_unit = self.ctfont.pt_size() as f64 / self.ctfont.units_per_em() as f64; result.px_per_font_unit = pt_to_px(pt_per_font_unit); - - debug_assert_eq!(n_pairs * KERN_PAIR_LEN, result.pair_data_range.len()); } start = end; } diff --git a/components/net/storage_thread.rs b/components/net/storage_thread.rs index c314dbdd8cd..cc329f08922 100644 --- a/components/net/storage_thread.rs +++ b/components/net/storage_thread.rs @@ -144,12 +144,15 @@ impl StorageManager { value: String) { let origin = self.origin_as_string(url); - let current_total_size = { + let (this_storage_size, other_storage_size) = { let local_data = self.select_data(StorageType::Local); let session_data = self.select_data(StorageType::Session); let local_data_size = local_data.get(&origin).map_or(0, |&(total, _)| total); let session_data_size = session_data.get(&origin).map_or(0, |&(total, _)| total); - local_data_size + session_data_size + match storage_type { + StorageType::Local => (local_data_size, session_data_size), + StorageType::Session => (session_data_size, local_data_size), + } }; let data = self.select_data_mut(storage_type); @@ -158,14 +161,14 @@ impl StorageManager { } let message = data.get_mut(&origin).map(|&mut (ref mut total, ref mut entry)| { - let mut new_total_size = current_total_size + value.as_bytes().len(); + let mut new_total_size = this_storage_size + value.as_bytes().len(); if let Some(old_value) = entry.get(&name) { new_total_size -= old_value.as_bytes().len(); } else { new_total_size += name.as_bytes().len(); } - if new_total_size > QUOTA_SIZE_LIMIT { + if (new_total_size + other_storage_size) > QUOTA_SIZE_LIMIT { return Err(()); } 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)] diff --git a/components/script/lib.rs b/components/script/lib.rs index 4f66095e1ff..ebc5b4a1686 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -6,7 +6,7 @@ #![feature(borrow_state)] #![feature(box_syntax)] #![feature(const_fn)] -#![cfg_attr(debug_assertions, feature(core_intrinsics))] +#![feature(core_intrinsics)] #![feature(custom_attribute)] #![feature(custom_derive)] #![feature(fnbox)] diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 05689baac39..8a7fc82f52e 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -200,11 +200,9 @@ impl<T: Runnable + Send> Runnable for CancellableRunnable<T> { pub trait Runnable { fn is_cancelled(&self) -> bool { false } - fn handler(self: Box<Self>); -} - -pub trait MainThreadRunnable { - fn handler(self: Box<Self>, script_thread: &ScriptThread); + fn name(&self) -> &'static str { "generic runnable" } + fn handler(self: Box<Self>) {} + fn main_thread_handler(self: Box<Self>, _script_thread: &ScriptThread) { self.handler(); } } enum MixedMessage { @@ -1223,7 +1221,7 @@ impl ScriptThread { // https://html.spec.whatwg.org/multipage/#the-end step 7 let handler = box DocumentProgressHandler::new(Trusted::new(doc)); - self.dom_manipulation_task_source.queue(DOMManipulationTask::DocumentProgress(handler)).unwrap(); + self.dom_manipulation_task_source.queue(DOMManipulationTask::Runnable(handler)).unwrap(); self.constellation_chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap(); } diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index fbe864a9005..a1c06f2c09e 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -5,7 +5,7 @@ use dom::bindings::refcounted::Trusted; use dom::event::{EventBubbles, EventCancelable}; use dom::eventtarget::EventTarget; -use script_thread::{MainThreadRunnable, MainThreadScriptMsg, Runnable, ScriptThread}; +use script_thread::{MainThreadScriptMsg, Runnable, ScriptThread}; use std::result::Result; use std::sync::mpsc::Sender; use string_cache::Atom; @@ -39,21 +39,12 @@ impl DOMManipulationTaskSource { } pub enum DOMManipulationTask { - // https://html.spec.whatwg.org/multipage/#the-end step 7 - DocumentProgress(Box<Runnable + Send>), // https://dom.spec.whatwg.org/#concept-event-fire FireEvent(Trusted<EventTarget>, Atom, EventBubbles, EventCancelable), // https://html.spec.whatwg.org/multipage/#fire-a-simple-event FireSimpleEvent(Trusted<EventTarget>, Atom), - // https://html.spec.whatwg.org/multipage/#details-notification-task-steps - FireToggleEvent(Box<Runnable + Send>), - // Placeholder until there's a real media element task queue implementation - MediaTask(Box<Runnable + Send>), - // https://html.spec.whatwg.org/multipage/#planned-navigation - PlannedNavigation(Box<Runnable + Send>), - // https://html.spec.whatwg.org/multipage/#send-a-storage-notification - SendStorageNotification(Box<MainThreadRunnable + Send>), - Miscellaneous(Box<Runnable + Send>), + + Runnable(Box<Runnable + Send>), } impl DOMManipulationTask { @@ -61,7 +52,6 @@ impl DOMManipulationTask { use self::DOMManipulationTask::*; match self { - DocumentProgress(runnable) => runnable.handler(), FireEvent(element, name, bubbles, cancelable) => { let target = element.root(); target.fire_event(&*name, bubbles, cancelable); @@ -70,11 +60,11 @@ impl DOMManipulationTask { let target = element.root(); target.fire_simple_event(&*name); } - FireToggleEvent(runnable) => runnable.handler(), - MediaTask(runnable) => runnable.handler(), - PlannedNavigation(runnable) => runnable.handler(), - SendStorageNotification(runnable) => runnable.handler(script_thread), - Miscellaneous(runnable) => runnable.handler(), + Runnable(runnable) => { + if !runnable.is_cancelled() { + runnable.main_thread_handler(script_thread); + } + } } } } diff --git a/components/util/lib.rs b/components/util/lib.rs index 15fdaa5f332..6ffa4a4a2b5 100644 --- a/components/util/lib.rs +++ b/components/util/lib.rs @@ -2,7 +2,6 @@ * 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/. */ -#![cfg_attr(feature = "servo", feature(core_intrinsics))] #![cfg_attr(feature = "servo", feature(custom_derive))] #![cfg_attr(feature = "servo", feature(fnbox))] #![cfg_attr(feature = "servo", feature(plugin))] @@ -41,12 +40,6 @@ pub mod resource_files; pub mod thread; pub mod thread_state; -#[cfg(feature = "servo")] -#[allow(unsafe_code)] -pub fn breakpoint() { - unsafe { ::std::intrinsics::breakpoint() }; -} - // Workaround for lack of `ptr_eq` on Arcs... #[inline] pub fn arc_ptr_eq<T: 'static>(a: &Arc<T>, b: &Arc<T>) -> bool { diff --git a/components/util/prefs.rs b/components/util/prefs.rs index d0d96a93035..eeb32a9a507 100644 --- a/components/util/prefs.rs +++ b/components/util/prefs.rs @@ -11,12 +11,12 @@ use std::collections::HashMap; use std::fs::File; use std::io::{Read, Write, stderr}; use std::path::PathBuf; -use std::sync::{Arc, Mutex}; +use std::sync::{Arc, RwLock}; lazy_static! { pub static ref PREFS: Preferences = { - let prefs = read_prefs().unwrap_or_else(|_| HashMap::new()); - Preferences(Arc::new(Mutex::new(prefs))) + let prefs = read_prefs().ok().unwrap_or_else(HashMap::new); + Preferences(Arc::new(RwLock::new(prefs))) }; } @@ -207,15 +207,15 @@ fn read_prefs() -> Result<HashMap<String, Pref>, ()> { read_prefs_from_file(file) } -pub struct Preferences(Arc<Mutex<HashMap<String, Pref>>>); +pub struct Preferences(Arc<RwLock<HashMap<String, Pref>>>); impl Preferences { pub fn get(&self, name: &str) -> Arc<PrefValue> { - self.0.lock().unwrap().get(name).map_or(Arc::new(PrefValue::Missing), |x| x.value().clone()) + self.0.read().unwrap().get(name).map_or(Arc::new(PrefValue::Missing), |x| x.value().clone()) } pub fn cloned(&self) -> HashMap<String, Pref> { - self.0.lock().unwrap().clone() + self.0.read().unwrap().clone() } pub fn is_mozbrowser_enabled(&self) -> bool { @@ -223,7 +223,7 @@ impl Preferences { } pub fn set(&self, name: &str, value: PrefValue) { - let mut prefs = self.0.lock().unwrap(); + let mut prefs = self.0.write().unwrap(); if let Some(pref) = prefs.get_mut(name) { pref.set(value); return; @@ -232,7 +232,7 @@ impl Preferences { } pub fn reset(&self, name: &str) -> Arc<PrefValue> { - let mut prefs = self.0.lock().unwrap(); + let mut prefs = self.0.write().unwrap(); let result = match prefs.get_mut(name) { None => return Arc::new(PrefValue::Missing), Some(&mut Pref::NoDefault(_)) => Arc::new(PrefValue::Missing), @@ -249,7 +249,7 @@ impl Preferences { pub fn reset_all(&self) { let names = { - self.0.lock().unwrap().keys().cloned().collect::<Vec<String>>() + self.0.read().unwrap().keys().cloned().collect::<Vec<String>>() }; for name in names.iter() { self.reset(name); @@ -257,6 +257,6 @@ impl Preferences { } pub fn extend(&self, extension: HashMap<String, Pref>) { - self.0.lock().unwrap().extend(extension); + self.0.write().unwrap().extend(extension); } } diff --git a/tests/wpt/harness/wptrunner/testharnessreport-servo.js b/tests/wpt/harness/wptrunner/testharnessreport-servo.js index d1b31676170..6464436c339 100644 --- a/tests/wpt/harness/wptrunner/testharnessreport-servo.js +++ b/tests/wpt/harness/wptrunner/testharnessreport-servo.js @@ -8,7 +8,7 @@ setup(props); add_completion_callback(function (tests, harness_status) { var id = location.pathname + location.search + location.hash; - alert("RESULT: " + JSON.stringify([ + console.log("ALERT: RESULT: " + JSON.stringify([ id, harness_status.status, harness_status.message, diff --git a/tests/wpt/metadata-css/css-transforms-1_dev/html/transform-table-007.htm.ini b/tests/wpt/metadata-css/css-transforms-1_dev/html/transform-table-007.htm.ini new file mode 100644 index 00000000000..839df62416d --- /dev/null +++ b/tests/wpt/metadata-css/css-transforms-1_dev/html/transform-table-007.htm.ini @@ -0,0 +1,3 @@ +[transform-table-007.htm] + type: reftest + disabled: https://github.com/servo/servo/issues/11574 diff --git a/tests/wpt/metadata/html/semantics/embedded-content/the-iframe-element/change_parentage.html.ini b/tests/wpt/metadata/html/semantics/embedded-content/the-iframe-element/change_parentage.html.ini new file mode 100644 index 00000000000..5c3ee2555e4 --- /dev/null +++ b/tests/wpt/metadata/html/semantics/embedded-content/the-iframe-element/change_parentage.html.ini @@ -0,0 +1,3 @@ +[change_parentage.html] + type: testharness + disabled: https://github.com/servo/servo/issues/11703 |