mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
script: Add a Constraint DOMException
for IndexedDB (#37605)
Add Constraint DOMException to handle the name conflict error in `IDBDatabase::createObjectStore` method. Testing: `./mach test-wpt tests/wpt/tests/IndexedDB/`, but it seems there are many test failures even in main branch already ([related comment](https://github.com/servo/servo/pull/37605#issuecomment-2993889163)). Fixes: #37571 --------- Signed-off-by: iamlockon <xdddxyyyxzzz123@gmail.com>
This commit is contained in:
parent
12d262ec23
commit
204af81d2c
4 changed files with 9 additions and 2 deletions
|
@ -98,6 +98,7 @@ pub(crate) fn throw_dom_exception(
|
||||||
Error::Operation => DOMErrorName::OperationError,
|
Error::Operation => DOMErrorName::OperationError,
|
||||||
Error::NotAllowed => DOMErrorName::NotAllowedError,
|
Error::NotAllowed => DOMErrorName::NotAllowedError,
|
||||||
Error::Encoding => DOMErrorName::EncodingError,
|
Error::Encoding => DOMErrorName::EncodingError,
|
||||||
|
Error::Constraint => DOMErrorName::ConstraintError,
|
||||||
Error::Type(message) => unsafe {
|
Error::Type(message) => unsafe {
|
||||||
assert!(!JS_IsExceptionPending(*cx));
|
assert!(!JS_IsExceptionPending(*cx));
|
||||||
throw_type_error(*cx, &message);
|
throw_type_error(*cx, &message);
|
||||||
|
|
|
@ -57,6 +57,7 @@ pub(crate) enum DOMErrorName {
|
||||||
NotReadableError,
|
NotReadableError,
|
||||||
OperationError,
|
OperationError,
|
||||||
NotAllowedError,
|
NotAllowedError,
|
||||||
|
ConstraintError,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DOMErrorName {
|
impl DOMErrorName {
|
||||||
|
@ -92,6 +93,7 @@ impl DOMErrorName {
|
||||||
"NotReadableError" => Some(DOMErrorName::NotReadableError),
|
"NotReadableError" => Some(DOMErrorName::NotReadableError),
|
||||||
"OperationError" => Some(DOMErrorName::OperationError),
|
"OperationError" => Some(DOMErrorName::OperationError),
|
||||||
"NotAllowedError" => Some(DOMErrorName::NotAllowedError),
|
"NotAllowedError" => Some(DOMErrorName::NotAllowedError),
|
||||||
|
"ConstraintError" => Some(DOMErrorName::ConstraintError),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,6 +158,9 @@ impl DOMException {
|
||||||
r#"The request is not allowed by the user agent or the platform in the current context,
|
r#"The request is not allowed by the user agent or the platform in the current context,
|
||||||
possibly because the user denied permission."#
|
possibly because the user denied permission."#
|
||||||
},
|
},
|
||||||
|
DOMErrorName::ConstraintError => {
|
||||||
|
"A mutation operation in a transaction failed because a constraint was not satisfied."
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
|
@ -213,8 +213,7 @@ impl IDBDatabaseMethods<crate::DomTypeHolder> for IDBDatabase {
|
||||||
.iter()
|
.iter()
|
||||||
.any(|store_name| store_name.to_string() == name.to_string())
|
.any(|store_name| store_name.to_string() == name.to_string())
|
||||||
{
|
{
|
||||||
// TODO: Add constraint as an dom exception and throw that instead
|
return Err(Error::Constraint);
|
||||||
return Err(Error::InvalidState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 7
|
// Step 7
|
||||||
|
|
|
@ -70,6 +70,8 @@ pub enum Error {
|
||||||
NotAllowed,
|
NotAllowed,
|
||||||
/// EncodingError DOMException
|
/// EncodingError DOMException
|
||||||
Encoding,
|
Encoding,
|
||||||
|
/// ConstraintError DOMException
|
||||||
|
Constraint,
|
||||||
|
|
||||||
/// TypeError JavaScript Error
|
/// TypeError JavaScript Error
|
||||||
Type(String),
|
Type(String),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue