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>
This commit is contained in:
Samson 2024-08-03 14:58:37 +02:00 committed by GitHub
parent fd83281657
commit f3bec0aed3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 291 additions and 20 deletions

View file

@ -72,7 +72,6 @@
expected: FAIL
[Window interface: calling fetch(RequestInfo, optional RequestInit) on window with too few arguments must throw TypeError]
expected: FAIL
[Window interface: operation fetch(RequestInfo, optional RequestInit)]
expected: FAIL
@ -170,7 +169,6 @@
expected: FAIL
[WorkerGlobalScope interface: calling fetch(RequestInfo, optional RequestInit) on self with too few arguments must throw TypeError]
expected: FAIL
[WorkerGlobalScope interface: operation fetch(RequestInfo, optional RequestInit)]
expected: FAIL

View file

@ -69,7 +69,6 @@
expected: FAIL
[WorkerGlobalScope interface: calling fetch(RequestInfo, optional RequestInit) on self with too few arguments must throw TypeError]
expected: FAIL
[Request interface: operation bytes()]
expected: FAIL
@ -158,7 +157,6 @@
expected: FAIL
[Window interface: calling fetch(RequestInfo, optional RequestInit) on window with too few arguments must throw TypeError]
expected: FAIL
[Request interface: operation bytes()]
expected: FAIL

View file

@ -0,0 +1,7 @@
[exceptionToRejection.any.html]
type: testharness
prefs: [dom.testbinding.enabled:true]
[exceptionToRejection.any.worker.html]
type: testharness
prefs: [dom.testbinding.enabled:true]

View file

@ -13130,6 +13130,31 @@
{}
]
],
"exceptionToRejection.any.js": [
"738a8bedbcfe83a6f110bc6e6d133e31f80ea9ad",
[
"mozilla/exceptionToRejection.any.html",
{
"script_metadata": [
[
"title",
"Test that promise exception are converted to rejections"
]
]
}
],
[
"mozilla/exceptionToRejection.any.worker.html",
{
"script_metadata": [
[
"title",
"Test that promise exception are converted to rejections"
]
]
}
]
],
"fetch_cannot_overwhelm_system.window.js": [
"989231e9caedd099f5212bd2f9d377c83f929a22",
[

View file

@ -0,0 +1,7 @@
[exceptionToRejection.any.html]
type: testharness
prefs: [dom.testbinding.enabled:true]
[exceptionToRejection.any.worker.html]
type: testharness
prefs: [dom.testbinding.enabled:true]

View file

@ -0,0 +1,32 @@
// META: title=Test that promise exception are converted to rejections
var binding = new TestBinding();
/*
static Promise<any> staticThrowToRejectPromise();
Promise<any> methodThrowToRejectPromise();
readonly attribute Promise<any> getterThrowToRejectPromise;
static Promise<any> staticInternalThrowToRejectPromise([EnforceRange] unsigned long long arg);
Promise<any> methodInternalThrowToRejectPromise([EnforceRange] unsigned long long arg);
*/
promise_test((t) => {
return promise_rejects_js(t, TypeError, TestBinding.staticThrowToRejectPromise());
}, "staticThrowToRejectPromise");
promise_test((t) => {
return promise_rejects_js(t, TypeError, binding.methodThrowToRejectPromise());
}, "methodThrowToRejectPromise");
promise_test((t) => {
return promise_rejects_js(t, TypeError, binding.getterThrowToRejectPromise);
}, "getterThrowToRejectPromise");
promise_test((t) => {
return promise_rejects_js(t, TypeError, TestBinding.staticInternalThrowToRejectPromise(Number.MAX_SAFE_INTEGER + 1));
}, "staticInternalThrowToRejectPromise");
promise_test((t) => {
return promise_rejects_js(t, TypeError, binding.methodInternalThrowToRejectPromise(Number.MAX_SAFE_INTEGER + 1));
}, "methodInternalThrowToRejectPromise");