mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
LibWeb/IDB: Implement is_a_potentially_valid_key_range
This commit is contained in:
committed by
Jelle Raaijmakers
parent
89f94845cf
commit
87af53a613
Notes:
github-actions[bot]
2025-08-27 14:15:57 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/87af53a613c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5385 Reviewed-by: https://github.com/gmta ✅
@@ -2083,4 +2083,35 @@ bool cleanup_indexed_database_transactions(GC::Ref<HTML::EventLoop> event_loop)
|
||||
return has_matching_event_loop;
|
||||
}
|
||||
|
||||
// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#potentially-valid-key-range
|
||||
bool is_a_potentially_valid_key_range(JS::Realm& realm, JS::Value value)
|
||||
{
|
||||
// 1. If value is a key range, return true.
|
||||
if (value.is_object() && is<IDBKeyRange>(value.as_object()))
|
||||
return true;
|
||||
|
||||
// 2. Else if Type(value) is Number, return true.
|
||||
if (value.is_number())
|
||||
return true;
|
||||
|
||||
// 3. Else if Type(value) is String, return true.
|
||||
if (value.is_string())
|
||||
return true;
|
||||
|
||||
// 4. Else if value is a Date (has a [[DateValue]] internal slot), return true.
|
||||
if (value.is_object() && value.as_object().is_date())
|
||||
return true;
|
||||
|
||||
// 5. Else if value is a buffer source type, return true.
|
||||
if (value.is_object() && (is<JS::TypedArrayBase>(value.as_object()) || is<JS::ArrayBuffer>(value.as_object()) || is<JS::DataView>(value.as_object())))
|
||||
return true;
|
||||
|
||||
// 6. Else if value is an Array exotic object, return true.
|
||||
if (value.is_object() && MUST(value.is_array(realm.vm())))
|
||||
return true;
|
||||
|
||||
// 7. Else return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,5 +58,6 @@ GC::Ref<JS::Array> retrieve_multiple_referenced_values_from_an_index(JS::Realm&,
|
||||
GC::Ref<JS::Array> retrieve_multiple_values_from_an_index(JS::Realm&, GC::Ref<Index>, GC::Ref<IDBKeyRange>, Optional<WebIDL::UnsignedLong>);
|
||||
void queue_a_database_task(GC::Ref<GC::Function<void()>>);
|
||||
bool cleanup_indexed_database_transactions(GC::Ref<HTML::EventLoop>);
|
||||
bool is_a_potentially_valid_key_range(JS::Realm&, JS::Value);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user