diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs index 4cee0c5a2cd..6b8fcc09e34 100644 --- a/components/script/dom/bindings/callback.rs +++ b/components/script/dom/bindings/callback.rs @@ -11,7 +11,6 @@ use dom::bindings::js::JSRef; use dom::bindings::utils::Reflectable; use js::jsapi::{JSContext, JSObject, JS_WrapObject, JS_ObjectIsCallable, JS_GetGlobalObject}; use js::jsapi::{JS_GetProperty, JS_IsExceptionPending, JS_ReportPendingException}; -use js::jsapi::{JS_GetPendingException}; use js::jsval::{JSVal, UndefinedValue}; use js::rust::with_compartment; @@ -137,7 +136,7 @@ pub struct CallSetup { /// The `JSContext` used for the call. cx: *mut JSContext, /// The exception handling used for the call. - handling: ExceptionHandling, + _handling: ExceptionHandling, } impl CallSetup { @@ -150,7 +149,7 @@ impl CallSetup { CallSetup { cx: cx, - handling: handling, + _handling: handling, } } @@ -162,31 +161,8 @@ impl CallSetup { impl Drop for CallSetup { fn drop(&mut self) { - let mut need_to_deal_with_exception = unsafe { JS_IsExceptionPending(self.cx) } != 0; - if self.handling == ExceptionHandling::Rethrow && need_to_deal_with_exception { - let mut exn = UndefinedValue(); - let got_exn = unsafe { - JS_GetPendingException(self.cx, &mut exn) != 0 - }; - - if got_exn { - //TODO: actually rethrow instead of eagerly reporting. - // Gecko stores a mutable reference to an ErrorResult - // abstraction that can store a JS exception and - // report it at content boundaries. Our return value - // wrappers around Result make that more difficult. - unsafe { - JS_ReportPendingException(self.cx); - } - need_to_deal_with_exception = false; - } - } - + let need_to_deal_with_exception = unsafe { JS_IsExceptionPending(self.cx) } != 0; if need_to_deal_with_exception { - // Either we're supposed to report our exceptions, or we're supposed to - // re-throw them but we failed to JS_GetPendingException. Either way, - // just report the pending exception, if any. - unsafe { let old_global = JS_GetGlobalObject(self.cx); with_compartment(self.cx, old_global, || {