mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Stop pretending to do anything except eagerly report pending exceptions after invoking a callback.
This commit is contained in:
parent
159235b3d0
commit
66fee39045
1 changed files with 3 additions and 27 deletions
|
@ -11,7 +11,6 @@ use dom::bindings::js::JSRef;
|
||||||
use dom::bindings::utils::Reflectable;
|
use dom::bindings::utils::Reflectable;
|
||||||
use js::jsapi::{JSContext, JSObject, JS_WrapObject, JS_ObjectIsCallable, JS_GetGlobalObject};
|
use js::jsapi::{JSContext, JSObject, JS_WrapObject, JS_ObjectIsCallable, JS_GetGlobalObject};
|
||||||
use js::jsapi::{JS_GetProperty, JS_IsExceptionPending, JS_ReportPendingException};
|
use js::jsapi::{JS_GetProperty, JS_IsExceptionPending, JS_ReportPendingException};
|
||||||
use js::jsapi::{JS_GetPendingException};
|
|
||||||
use js::jsval::{JSVal, UndefinedValue};
|
use js::jsval::{JSVal, UndefinedValue};
|
||||||
use js::rust::with_compartment;
|
use js::rust::with_compartment;
|
||||||
|
|
||||||
|
@ -137,7 +136,7 @@ pub struct CallSetup {
|
||||||
/// The `JSContext` used for the call.
|
/// The `JSContext` used for the call.
|
||||||
cx: *mut JSContext,
|
cx: *mut JSContext,
|
||||||
/// The exception handling used for the call.
|
/// The exception handling used for the call.
|
||||||
handling: ExceptionHandling,
|
_handling: ExceptionHandling,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CallSetup {
|
impl CallSetup {
|
||||||
|
@ -150,7 +149,7 @@ impl CallSetup {
|
||||||
|
|
||||||
CallSetup {
|
CallSetup {
|
||||||
cx: cx,
|
cx: cx,
|
||||||
handling: handling,
|
_handling: handling,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,31 +161,8 @@ impl CallSetup {
|
||||||
|
|
||||||
impl Drop for CallSetup {
|
impl Drop for CallSetup {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let mut need_to_deal_with_exception = unsafe { JS_IsExceptionPending(self.cx) } != 0;
|
let 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<U,V> make that more difficult.
|
|
||||||
unsafe {
|
|
||||||
JS_ReportPendingException(self.cx);
|
|
||||||
}
|
|
||||||
need_to_deal_with_exception = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if need_to_deal_with_exception {
|
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 {
|
unsafe {
|
||||||
let old_global = JS_GetGlobalObject(self.cx);
|
let old_global = JS_GetGlobalObject(self.cx);
|
||||||
with_compartment(self.cx, old_global, || {
|
with_compartment(self.cx, old_global, || {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue