Propagate JSFailed error & conditionally execute initial assertion when converting error to JS value.

This commit is contained in:
Julien Tregoat 2019-06-28 00:34:56 -04:00
parent fb7aa7ba7c
commit 28fcde9e10
4 changed files with 13 additions and 10 deletions

View file

@ -303,7 +303,10 @@ impl Error {
global: &GlobalScope,
rval: MutableHandleValue,
) {
assert!(!JS_IsExceptionPending(cx));
match self {
Error::JSFailed => (),
_ => assert!(!JS_IsExceptionPending(cx)),
}
throw_dom_exception(cx, global, self);
assert!(JS_IsExceptionPending(cx));
assert!(JS_GetPendingException(cx, rval));

View file

@ -31,8 +31,6 @@ const DIALOG_TITLE: &'static str = "Permission request dialog";
const NONSECURE_DIALOG_MESSAGE: &'static str = "feature is only safe to use in secure context,\
but servo can't guarantee\n that the current context is secure. Do you want to proceed and grant permission?";
const REQUEST_DIALOG_MESSAGE: &'static str = "Do you want to grant permission for";
const ROOT_DESC_CONVERSION_ERROR: &'static str =
"Can't convert to an IDL value of type PermissionDescriptor";
pub trait PermissionAlgorithm {
type Descriptor;
@ -237,7 +235,7 @@ impl PermissionAlgorithm for Permissions {
match PermissionDescriptor::new(cx, property.handle()) {
Ok(ConversionResult::Success(descriptor)) => Ok(descriptor),
Ok(ConversionResult::Failure(error)) => Err(Error::Type(error.into_owned())),
Err(_) => Err(Error::Type(String::from(ROOT_DESC_CONVERSION_ERROR))),
Err(_) => Err(Error::JSFailed),
}
}
}

View file

@ -1,6 +1,10 @@
[interfaces.any.html]
expected: CRASH
[Permissions interface: operation query(object)]
expected: FAIL
[Permissions interface: calling query(object) on navigator.permissions with too few arguments must throw TypeError]
expected: FAIL
[interfaces.any.worker.html]
expected: CRASH
expected: CRASH

View file

@ -1,5 +1,3 @@
[test-background-fetch-permission.html]
expected: CRASH
[Test Background Fetch Permission.]
expected: FAIL
expected: FAIL