aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/testbinding.rs
diff options
context:
space:
mode:
authorSamson <16504129+sagudev@users.noreply.github.com>2024-08-03 14:58:37 +0200
committerGitHub <noreply@github.com>2024-08-03 12:58:37 +0000
commitf3bec0aed386615e850b9e24b74c697624c32bce (patch)
tree24715d0908c90d652e976fb749fbb5c4e50e1a25 /components/script/dom/testbinding.rs
parentfd832816572e26cafb8207d3710bd704f2617758 (diff)
downloadservo-f3bec0aed386615e850b9e24b74c697624c32bce.tar.gz
servo-f3bec0aed386615e850b9e24b74c697624c32bce.zip
bindings: Convert certain Exceptions into Promise rejections (#32923)
* Impl promise exception to rejection for methods Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Impl promise exception to rejection for getters Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Impl promise exception to rejection for static methods Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Add tests for exception to rejection Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Diffstat (limited to 'components/script/dom/testbinding.rs')
-rw-r--r--components/script/dom/testbinding.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs
index 344d41af031..0177a6d89d1 100644
--- a/components/script/dom/testbinding.rs
+++ b/components/script/dom/testbinding.rs
@@ -1084,6 +1084,29 @@ impl TestBindingMethods for TestBinding {
stringMember: Some(s2),
}
}
+
+ fn MethodThrowToRejectPromise(&self) -> Fallible<Rc<Promise>> {
+ Err(Error::Type("test".to_string()))
+ }
+
+ fn GetGetterThrowToRejectPromise(&self) -> Fallible<Rc<Promise>> {
+ Err(Error::Type("test".to_string()))
+ }
+
+ fn MethodInternalThrowToRejectPromise(&self, _arg: u64) -> Rc<Promise> {
+ unreachable!("Method should already throw")
+ }
+}
+
+#[allow(non_snake_case)]
+impl TestBinding {
+ pub fn StaticThrowToRejectPromise(_: &GlobalScope) -> Fallible<Rc<Promise>> {
+ Err(Error::Type("test".to_string()))
+ }
+
+ pub fn StaticInternalThrowToRejectPromise(_: &GlobalScope, _arg: u64) -> Rc<Promise> {
+ unreachable!("Method should already throw")
+ }
}
#[allow(non_snake_case)]