mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Throw a TypeError when get_callable_property encounters a value that isn't callable.
This commit is contained in:
parent
0607cd3fb5
commit
90a7ef1571
3 changed files with 8 additions and 14 deletions
|
@ -99,16 +99,15 @@ impl CallbackInterface {
|
|||
-> Fallible<JSVal> {
|
||||
let mut callable = UndefinedValue();
|
||||
unsafe {
|
||||
let name = CString::new(name).unwrap();
|
||||
if JS_GetProperty(cx, self.callback(), name.as_ptr(), &mut callable) == 0 {
|
||||
let c_name = CString::new(name).unwrap();
|
||||
if JS_GetProperty(cx, self.callback(), c_name.as_ptr(), &mut callable) == 0 {
|
||||
return Err(Error::JSFailed);
|
||||
}
|
||||
|
||||
if !callable.is_object() ||
|
||||
JS_ObjectIsCallable(cx, callable.to_object()) == 0 {
|
||||
// FIXME(#347)
|
||||
//ThrowErrorMessage(cx, MSG_NOT_CALLABLE, description.get());
|
||||
return Err(Error::JSFailed);
|
||||
return Err(Error::Type(
|
||||
format!("The value of the {} property is not callable", name)));
|
||||
}
|
||||
}
|
||||
Ok(callable)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue