mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Make report_pending_exception unsafe
This commit is contained in:
parent
bc52617d33
commit
27620320f3
3 changed files with 12 additions and 8 deletions
|
@ -121,12 +121,10 @@ pub unsafe fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef, result:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Report a pending exception, thereby clearing it.
|
/// Report a pending exception, thereby clearing it.
|
||||||
pub fn report_pending_exception(cx: *mut JSContext, obj: *mut JSObject) {
|
pub unsafe fn report_pending_exception(cx: *mut JSContext, obj: *mut JSObject) {
|
||||||
unsafe {
|
if JS_IsExceptionPending(cx) {
|
||||||
if JS_IsExceptionPending(cx) {
|
let _ac = JSAutoCompartment::new(cx, obj);
|
||||||
let _ac = JSAutoCompartment::new(cx, obj);
|
JS_ReportPendingException(cx);
|
||||||
JS_ReportPendingException(cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -425,7 +425,9 @@ impl EventTarget {
|
||||||
};
|
};
|
||||||
if !rv || handler.ptr.is_null() {
|
if !rv || handler.ptr.is_null() {
|
||||||
// Step 1.8.2
|
// Step 1.8.2
|
||||||
report_pending_exception(cx, self.reflector().get_jsobject().get());
|
unsafe {
|
||||||
|
report_pending_exception(cx, self.reflector().get_jsobject().get());
|
||||||
|
}
|
||||||
// Step 1.8.1 / 1.8.3
|
// Step 1.8.1 / 1.8.3
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -416,6 +416,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
||||||
|
|
||||||
|
|
||||||
impl WorkerGlobalScope {
|
impl WorkerGlobalScope {
|
||||||
|
#[allow(unsafe_code)]
|
||||||
pub fn execute_script(&self, source: DOMString) {
|
pub fn execute_script(&self, source: DOMString) {
|
||||||
let mut rval = RootedValue::new(self.runtime.cx(), UndefinedValue());
|
let mut rval = RootedValue::new(self.runtime.cx(), UndefinedValue());
|
||||||
match self.runtime.evaluate_script(
|
match self.runtime.evaluate_script(
|
||||||
|
@ -428,7 +429,10 @@ impl WorkerGlobalScope {
|
||||||
// TODO: An error needs to be dispatched to the parent.
|
// TODO: An error needs to be dispatched to the parent.
|
||||||
// https://github.com/servo/servo/issues/6422
|
// https://github.com/servo/servo/issues/6422
|
||||||
println!("evaluate_script failed");
|
println!("evaluate_script failed");
|
||||||
report_pending_exception(self.runtime.cx(), self.reflector().get_jsobject().get());
|
unsafe {
|
||||||
|
report_pending_exception(
|
||||||
|
self.runtime.cx(), self.reflector().get_jsobject().get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue