diff options
Diffstat (limited to 'components/script/dom/bindings')
-rw-r--r-- | components/script/dom/bindings/callback.rs | 14 | ||||
-rw-r--r-- | components/script/dom/bindings/error.rs | 3 |
2 files changed, 7 insertions, 10 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); |