aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorJulien Tregoat <jules@jules.nyc>2019-06-28 00:34:56 -0400
committerJulien Tregoat <jules@jules.nyc>2019-07-03 13:48:48 -0400
commit28fcde9e10ba19bfd96bc758f2de3ca1c3688b7a (patch)
tree71e4e267f6e918bce59cf9ee4ff095e4578ab879 /components/script/dom
parentfb7aa7ba7c2ab35a80be764f67703f6aca8b9186 (diff)
downloadservo-28fcde9e10ba19bfd96bc758f2de3ca1c3688b7a.tar.gz
servo-28fcde9e10ba19bfd96bc758f2de3ca1c3688b7a.zip
Propagate JSFailed error & conditionally execute initial assertion when converting error to JS value.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bindings/error.rs5
-rw-r--r--components/script/dom/permissions.rs4
2 files changed, 5 insertions, 4 deletions
diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs
index da460ad94b6..5953a013d6d 100644
--- a/components/script/dom/bindings/error.rs
+++ b/components/script/dom/bindings/error.rs
@@ -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));
diff --git a/components/script/dom/permissions.rs b/components/script/dom/permissions.rs
index 87dc88636da..5c6d7b0aed0 100644
--- a/components/script/dom/permissions.rs
+++ b/components/script/dom/permissions.rs
@@ -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),
}
}
}