mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Implement IDBFactory::cmp
This commit is contained in:
parent
c43b93e6fa
commit
331f26a88b
Notes:
github-actions[bot]
2024-11-25 10:54:47 +00:00
Author: https://github.com/stelar7
Commit: 331f26a88b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2279
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/tcl3
14 changed files with 655 additions and 1 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <LibWeb/IndexedDB/IDBDatabase.h>
|
||||
#include <LibWeb/IndexedDB/IDBFactory.h>
|
||||
#include <LibWeb/IndexedDB/Internal/Algorithms.h>
|
||||
#include <LibWeb/IndexedDB/Internal/Key.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
#include <LibWeb/StorageAPI/StorageKey.h>
|
||||
|
||||
|
@ -93,4 +94,25 @@ WebIDL::ExceptionOr<GC::Ref<IDBOpenDBRequest>> IDBFactory::open(String const& na
|
|||
return request;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#dom-idbfactory-cmp
|
||||
WebIDL::ExceptionOr<i8> IDBFactory::cmp(JS::Value first, JS::Value second)
|
||||
{
|
||||
// 1. Let a be the result of converting a value to a key with first. Rethrow any exceptions.
|
||||
auto a = convert_a_value_to_a_key(realm(), first);
|
||||
|
||||
// 2. If a is invalid, throw a "DataError" DOMException.
|
||||
if (a.is_error())
|
||||
return WebIDL::DataError::create(realm(), "Failed to convert a value to a key"_string);
|
||||
|
||||
// 3. Let b be the result of converting a value to a key with second. Rethrow any exceptions.
|
||||
auto b = convert_a_value_to_a_key(realm(), second);
|
||||
|
||||
// 4. If b is invalid, throw a "DataError" DOMException.
|
||||
if (b.is_error())
|
||||
return WebIDL::DataError::create(realm(), "Failed to convert a value to a key"_string);
|
||||
|
||||
// 5. Return the results of comparing two keys with a and b.
|
||||
return Key::compare_two_keys(a.release_value(), b.release_value());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue