Skip to content

Truly independent web browser

LibWeb: Update IndexedDB step comments to the latest spec

Shannon Booth6835c88c6e40
diff --git a/Libraries/LibWeb/IndexedDB/IDBCursor.cpp b/Libraries/LibWeb/IndexedDB/IDBCursor.cpp
index 58883148052..85b965a89dd 100644
--- a/Libraries/LibWeb/IndexedDB/IDBCursor.cpp
+++ b/Libraries/LibWeb/IndexedDB/IDBCursor.cpp
@@ -50,11 +50,11 @@ JS::Value IDBCursor::primary_key(JS::Realm& realm)
}
IDBCursor::IDBCursor(CursorSourceHandle source_handle, GC::Ptr<Key> position, CursorDirection direction, GotValue got_value, GC::Ptr<Key> key, JS::Value value, GC::Ref<IDBKeyRange> range, KeyOnly key_only)
- : m_value(value)
+ : m_key(key)
+ , m_value(value)
, m_position(position)
, m_direction(direction)
, m_got_value(got_value == GotValue::Yes)
- , m_key(key)
, m_source_handle(source_handle)
, m_range(range)
, m_key_only(key_only == KeyOnly::Yes)
@@ -161,7 +161,7 @@ WebIDL::ExceptionOr<void> IDBCursor::continue_(Optional<JS::Value> key)
// 1. Let r be the result of converting a value to a key with key. Rethrow any exceptions.
auto r = TRY(convert_a_value_to_a_key(realm, *key));
- // 2. If r is invalid, throw a "DataError" DOMException.
+ // 2. If r is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (r->is_invalid())
return WebIDL::DataError::create(r->value_as_string());
@@ -298,7 +298,7 @@ WebIDL::ExceptionOr<void> IDBCursor::continue_primary_key(JS::Value key_param, J
// 7. Let r be the result of converting a value to a key with key. Rethrow any exceptions.
auto r = TRY(convert_a_value_to_a_key(realm, key_param));
- // 8. If r is invalid, throw a "DataError" DOMException.
+ // 8. If r is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (r->is_invalid())
return WebIDL::DataError::create(r->value_as_string());
@@ -308,7 +308,7 @@ WebIDL::ExceptionOr<void> IDBCursor::continue_primary_key(JS::Value key_param, J
// 10. Let r be the result of converting a value to a key with primaryKey. Rethrow any exceptions.
r = TRY(convert_a_value_to_a_key(realm, primary_key_param));
- // 11. If r is invalid, throw a "DataError" DOMException.
+ // 11. If r is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (r->is_invalid())
return WebIDL::DataError::create(r->value_as_string());
@@ -439,7 +439,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBCursor::update(JS::Value value)
return request;
}
-// https://w3c.github.io/IndexedDB/#dom-idbcursor-update
+// https://w3c.github.io/IndexedDB/#dom-idbcursor-delete
WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBCursor::delete_()
{
auto& realm = HTML::relevant_realm(relevant_global_object());
diff --git a/Libraries/LibWeb/IndexedDB/IDBCursor.h b/Libraries/LibWeb/IndexedDB/IDBCursor.h
index de8b7ebfa28..b9ac80c1e74 100644
--- a/Libraries/LibWeb/IndexedDB/IDBCursor.h
+++ b/Libraries/LibWeb/IndexedDB/IDBCursor.h
@@ -78,7 +78,8 @@ protected:
explicit IDBCursor(CursorSourceHandle, GC::Ptr<Key>, CursorDirection, GotValue, GC::Ptr<Key>, JS::Value, GC::Ref<IDBKeyRange>, KeyOnly);
virtual void visit_edges(GC::Cell::Visitor& visitor) override;
- // A cursor has a value which represent the value of the last iterated record.
+ // A cursor has a key and a value which represent the key and the value of the last iterated record.
+ GC::Ptr<Key> m_key;
Optional<JS::Value> m_value;
private:
@@ -94,9 +95,6 @@ private:
// A cursor has a got value flag.
bool m_got_value { false };
- // A cursor has a key which represent the key the last iterated record.
- GC::Ptr<Key> m_key;
-
// A cursor has a source handle, which is the index handle or the object store handle that opened the cursor.
CursorSourceHandle m_source_handle;
diff --git a/Libraries/LibWeb/IndexedDB/IDBDatabase.h b/Libraries/LibWeb/IndexedDB/IDBDatabase.h
index 2fa2b3b3a1d..b92994c443d 100644
--- a/Libraries/LibWeb/IndexedDB/IDBDatabase.h
+++ b/Libraries/LibWeb/IndexedDB/IDBDatabase.h
@@ -22,7 +22,7 @@ using ObjectStoreParameters = Bindings::IDBObjectStoreParameters;
using TransactionOptions = Bindings::IDBTransactionOptions;
// https://w3c.github.io/IndexedDB/#IDBDatabase-interface
-// https://www.w3.org/TR/IndexedDB/#database-connection
+// https://w3c.github.io/IndexedDB/#database-connection
class IDBDatabase : public DOM::EventTarget {
WEB_WRAPPABLE(IDBDatabase, DOM::EventTarget);
GC_DECLARE_ALLOCATOR(IDBDatabase);
diff --git a/Libraries/LibWeb/IndexedDB/IDBFactory.cpp b/Libraries/LibWeb/IndexedDB/IDBFactory.cpp
index eb3651d203e..4494b8f479e 100644
--- a/Libraries/LibWeb/IndexedDB/IDBFactory.cpp
+++ b/Libraries/LibWeb/IndexedDB/IDBFactory.cpp
@@ -107,7 +107,9 @@ WebIDL::ExceptionOr<GC::Ref<IDBOpenDBRequest>> IDBFactory::open(Utf16String cons
HTML::EventNames::error,
{ .bubbles = true, .cancelable = true },
current_high_resolution_time(request->relevant_global_scope())));
- } else {
+ }
+ // 2. Otherwise:
+ else {
// 1. Set request’s result to result.
Bindings::set_idb_request_result(realm, request, result.release_value());
@@ -132,14 +134,14 @@ 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 = TRY(convert_a_value_to_a_key(HTML::relevant_realm(relevant_global_object()), first));
- // 2. If a is invalid, throw a "DataError" DOMException.
+ // 2. If a is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (a->is_invalid())
return WebIDL::DataError::create("Failed to convert a value to a key"_utf16);
// 3. Let b be the result of converting a value to a key with second. Rethrow any exceptions.
auto b = TRY(convert_a_value_to_a_key(HTML::relevant_realm(relevant_global_object()), second));
- // 4. If b is invalid, throw a "DataError" DOMException.
+ // 4. If b is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (b->is_invalid())
return WebIDL::DataError::create("Failed to convert a value to a key"_utf16);
@@ -175,25 +177,21 @@ WebIDL::ExceptionOr<GC::Ref<IDBOpenDBRequest>> IDBFactory::delete_database(Utf16
// 3. Queue a database task to run these steps:
queue_a_database_task(GC::create_function(GC::Heap::the(), [&realm, request, result = move(result)]() mutable {
- // 1. If result is an error,
+ // 1. If result is an error, set request’s error to result, set request’s done flag to true, and fire an event
+ // named error at request with its bubbles and cancelable attributes initialized to true.
if (result.is_error()) {
- // set request’s error to result,
request->set_error(result.exception().get<GC::Ref<WebIDL::DOMException>>());
- // set request’s done flag to true,
request->set_done(true);
- // and fire an event named error at request with its bubbles and cancelable attributes initialized to true.
request->dispatch_event(DOM::Event::create(
HTML::EventNames::error,
{ .bubbles = true, .cancelable = true },
current_high_resolution_time(request->relevant_global_scope())));
}
- // 2. Otherwise,
+ // 2. Otherwise, set request’s result to undefined, set request’s done flag to true, and fire a version change
+ // event named success at request with result and null.
else {
- // set request’s result to undefined,
request->set_result(JS::js_undefined());
- // set request’s done flag to true,
request->set_done(true);
- // and fire a version change event named success at request with result and null.
auto value = result.release_value();
fire_a_version_change_event(realm, HTML::EventNames::success, request, value, {});
}
@@ -231,21 +229,30 @@ void IDBFactory::databases(GC::Ref<WebIDL::Promise> promise)
auto storage_key = maybe_storage_key.release_value();
// 3. Let p be a new promise.
+ // NB: p is the promise that databases() created.
// 4. Run these steps in parallel:
Platform::EventLoopPlugin::the().deferred_invoke(GC::create_function(GC::Heap::the(), [&realm, storage_key, promise]() {
HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
// 1. Let databases be the set of databases in storageKey.
- // If this cannot be determined for any reason, then reject p with an appropriate error (e.g. an "UnknownError" DOMException) and terminate these steps.
+ // If this cannot be determined for any reason, then queue a database task to reject p with an appropriate error (e.g. an "UnknownError" DOMException) and terminate these steps.
auto databases = Database::for_key(storage_key);
// 2. Let result be a new list.
- // 3. For each db of databases, append an IDBDatabaseInfo dictionary
- // if db's version is not 0.
- // 4. Resolve p with result.
+ // 3. For each db of databases:
+ // 1. If db's version is 0, then continue.
+ // 2. Let info be a new IDBDatabaseInfo dictionary.
+ // 3. Set info's name dictionary member to db's name.
+ // 4. Set info's version dictionary member to db's version.
+ // 5. Append info to result.
+ // 4. Queue a database task to resolve p with result.
+ // AD-HOC: p is resolved directly in a deferred invocation, not in a database task.
Bindings::resolve_database_info_list_promise(realm, promise, databases);
}));
+
+ // 5. Return p.
+ // NB: databases() returns p.
}
}
diff --git a/Libraries/LibWeb/IndexedDB/IDBIndex.idl b/Libraries/LibWeb/IndexedDB/IDBIndex.idl
index 56bde244b85..905bf0a2ce9 100644
--- a/Libraries/LibWeb/IndexedDB/IDBIndex.idl
+++ b/Libraries/LibWeb/IndexedDB/IDBIndex.idl
@@ -7,8 +7,8 @@ interface IDBIndex {
readonly attribute boolean unique;
[NewObject] IDBRequest get(any query);
[NewObject] IDBRequest getKey(any query);
- [NewObject] IDBRequest getAll(optional any query, optional [EnforceRange] unsigned long count);
- [NewObject] IDBRequest getAllKeys(optional any query, optional [EnforceRange] unsigned long count);
+ [NewObject] IDBRequest getAll(optional any queryOrOptions, optional [EnforceRange] unsigned long count);
+ [NewObject] IDBRequest getAllKeys(optional any queryOrOptions, optional [EnforceRange] unsigned long count);
[NewObject] IDBRequest getAllRecords(optional IDBGetAllOptions options = {});
[NewObject] IDBRequest count(optional any query);
[NewObject] IDBRequest openCursor(optional any query, optional IDBCursorDirection direction = "next");
diff --git a/Libraries/LibWeb/IndexedDB/IDBKeyRange.cpp b/Libraries/LibWeb/IndexedDB/IDBKeyRange.cpp
index c5da3cadb86..0ed99611424 100644
--- a/Libraries/LibWeb/IndexedDB/IDBKeyRange.cpp
+++ b/Libraries/LibWeb/IndexedDB/IDBKeyRange.cpp
@@ -69,7 +69,7 @@ WebIDL::ExceptionOr<GC::Ref<IndexedDB::IDBKeyRange>> only(JS::Realm& realm, JS::
// 1. Let key be the result of converting a value to a key with value. Rethrow any exceptions.
auto key = TRY(IndexedDB::convert_a_value_to_a_key(realm, value));
- // 2. If key is invalid, throw a "DataError" DOMException.
+ // 2. If key is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (key->is_invalid())
return WebIDL::DataError::create(realm, "Value is invalid"_utf16);
@@ -97,7 +97,7 @@ WebIDL::ExceptionOr<GC::Ref<IndexedDB::IDBKeyRange>> upper_bound(JS::Realm& real
// 1. Let upperKey be the result of converting a value to a key with upper. Rethrow any exceptions.
auto key = TRY(IndexedDB::convert_a_value_to_a_key(realm, upper));
- // 2. If upperKey is invalid, throw a "DataError" DOMException.
+ // 2. If upperKey is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (key->is_invalid())
return WebIDL::DataError::create(realm, "Value is invalid"_utf16);
@@ -111,14 +111,14 @@ WebIDL::ExceptionOr<GC::Ref<IndexedDB::IDBKeyRange>> bound(JS::Realm& realm, JS:
// 1. Let lowerKey be the result of converting a value to a key with lower. Rethrow any exceptions.
auto lower_key = TRY(IndexedDB::convert_a_value_to_a_key(realm, lower));
- // 2. If lowerKey is invalid, throw a "DataError" DOMException.
+ // 2. If lowerKey is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (lower_key->is_invalid())
return WebIDL::DataError::create(realm, "Value is invalid"_utf16);
// 3. Let upperKey be the result of converting a value to a key with upper. Rethrow any exceptions.
auto upper_key = TRY(IndexedDB::convert_a_value_to_a_key(realm, upper));
- // 4. If upperKey is invalid, throw a "DataError" DOMException.
+ // 4. If upperKey is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (upper_key->is_invalid())
return WebIDL::DataError::create(realm, "Value is invalid"_utf16);
@@ -136,7 +136,7 @@ WebIDL::ExceptionOr<bool> includes(JS::Realm& realm, IndexedDB::IDBKeyRange& key
// 1. Let k be the result of converting a value to a key with key. Rethrow any exceptions.
auto converted_key = TRY(IndexedDB::convert_a_value_to_a_key(realm, key));
- // 2. If k is invalid, throw a "DataError" DOMException.
+ // 2. If k is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (converted_key->is_invalid())
return WebIDL::DataError::create(realm, "Value is invalid"_utf16);
diff --git a/Libraries/LibWeb/IndexedDB/IDBKeyRange.idl b/Libraries/LibWeb/IndexedDB/IDBKeyRange.idl
index 459cb1757d4..2ee91ed08a6 100644
--- a/Libraries/LibWeb/IndexedDB/IDBKeyRange.idl
+++ b/Libraries/LibWeb/IndexedDB/IDBKeyRange.idl
@@ -5,6 +5,7 @@ interface IDBKeyRange {
readonly attribute boolean lowerOpen;
readonly attribute boolean upperOpen;
+ // Static construction methods:
[ImplementedInBindings, NeedsCallerRealm, NewObject] static IDBKeyRange only(any value);
[ImplementedInBindings, NeedsCallerRealm, NewObject] static IDBKeyRange lowerBound(any lower, optional boolean open = false);
[ImplementedInBindings, NeedsCallerRealm, NewObject] static IDBKeyRange upperBound(any upper, optional boolean open = false);
diff --git a/Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp b/Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp
index 517e93912d7..3522571548e 100644
--- a/Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp
+++ b/Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp
@@ -317,7 +317,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBObjectStore::add_or_put(GC::Ref<IDBO
// 1. Let r be the result of converting a value to a key with key. Rethrow any exceptions.
auto r = TRY(convert_a_value_to_a_key(realm, key.value()));
- // 2. If r is invalid, throw a "DataError" DOMException.
+ // 2. If r is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (r->is_invalid())
return WebIDL::DataError::create("Key is invalid"_utf16);
@@ -352,7 +352,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBObjectStore::add_or_put(GC::Ref<IDBO
if (!store.uses_a_key_generator())
return WebIDL::DataError::create("Store does not have a key generator"_utf16);
- // 2. Otherwise, if check that a key could be injected into a value with clone and store’s key path return false, throw a "DataError" DOMException.
+ // 2. If check that a key could be injected into a value with clone and store’s key path return false, throw a "DataError" DOMException.
if (!check_that_a_key_could_be_injected_into_a_value(realm, clone, store.key_path().value()))
return WebIDL::DataError::create("Key could not be injected into value"_utf16);
}
@@ -660,7 +660,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBObjectStore::get_all_keys(Optional<J
return create_a_request_to_retrieve_multiple_items(HTML::relevant_realm(relevant_global_object()), GC::Ref(*this), RecordKind::Key, query_or_options.value_or(JS::js_undefined()), count);
}
-// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#dom-idbobjectstore-getallrecords
+// https://w3c.github.io/IndexedDB/#dom-idbobjectstore-getallrecords
WebIDL::ExceptionOr<GC::Ref<IDBRequest>> IDBObjectStore::get_all_records(RetrieveMultipleItemsOptions const& options)
{
// 1. Return the result of creating a request to retrieve multiple items with the current Realm record, this,
diff --git a/Libraries/LibWeb/IndexedDB/IDBObjectStore.idl b/Libraries/LibWeb/IndexedDB/IDBObjectStore.idl
index 6d31aedf81b..01617c80db9 100644
--- a/Libraries/LibWeb/IndexedDB/IDBObjectStore.idl
+++ b/Libraries/LibWeb/IndexedDB/IDBObjectStore.idl
@@ -12,8 +12,8 @@ interface IDBObjectStore {
[NewObject] IDBRequest clear();
[NewObject] IDBRequest get(any query);
[NewObject] IDBRequest getKey(any query);
- [NewObject] IDBRequest getAll(optional any query, optional [EnforceRange] unsigned long count);
- [NewObject] IDBRequest getAllKeys(optional any query, optional [EnforceRange] unsigned long count);
+ [NewObject] IDBRequest getAll(optional any queryOrOptions, optional [EnforceRange] unsigned long count);
+ [NewObject] IDBRequest getAllKeys(optional any queryOrOptions, optional [EnforceRange] unsigned long count);
[NewObject] IDBRequest getAllRecords(optional IDBGetAllOptions options = {});
[NewObject] IDBRequest count(optional any query);
[NewObject] IDBRequest openCursor(optional any query, optional IDBCursorDirection direction = "next");
diff --git a/Libraries/LibWeb/IndexedDB/IDBRecord.h b/Libraries/LibWeb/IndexedDB/IDBRecord.h
index 978f86f18a1..3e48bfccfef 100644
--- a/Libraries/LibWeb/IndexedDB/IDBRecord.h
+++ b/Libraries/LibWeb/IndexedDB/IDBRecord.h
@@ -44,8 +44,8 @@ struct IndexRecord {
GC::Ref<Key> value;
};
-// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#record-snapshot
-// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/461/95f98c0...43e154b.html#record-interface
+// https://w3c.github.io/IndexedDB/#record-snapshot
+// https://w3c.github.io/IndexedDB/#record-interface
class IDBRecord : public Bindings::GCAllocatedWrappable {
WEB_WRAPPABLE(IDBRecord, Bindings::GCAllocatedWrappable);
GC_DECLARE_ALLOCATOR(IDBRecord);
diff --git a/Libraries/LibWeb/IndexedDB/IDBRecord.idl b/Libraries/LibWeb/IndexedDB/IDBRecord.idl
index 94d473a44e8..a9b85c2be35 100644
--- a/Libraries/LibWeb/IndexedDB/IDBRecord.idl
+++ b/Libraries/LibWeb/IndexedDB/IDBRecord.idl
@@ -1,4 +1,4 @@
-// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#record-interface
+// https://w3c.github.io/IndexedDB/#record-interface
[Exposed=(Window,Worker)]
interface IDBRecord {
[NeedsCallerRealm] readonly attribute any key;
diff --git a/Libraries/LibWeb/IndexedDB/IDBRequest.cpp b/Libraries/LibWeb/IndexedDB/IDBRequest.cpp
index d65fbfabb25..c1e4755fde3 100644
--- a/Libraries/LibWeb/IndexedDB/IDBRequest.cpp
+++ b/Libraries/LibWeb/IndexedDB/IDBRequest.cpp
@@ -44,7 +44,7 @@ WebIDL::ExceptionOr<JS::Value> IDBRequest::result() const
if (!done())
return WebIDL::InvalidStateError::create("The request is not done"_utf16);
- // 2. Otherwise, return this's result, or undefined if the request resulted in an error.
+ // 2. Return this's result, or undefined if the request resulted in an error.
if (has_error())
return JS::js_undefined();
@@ -109,7 +109,7 @@ WebIDL::ExceptionOr<GC::Ptr<WebIDL::DOMException>> IDBRequest::error() const
if (!m_done)
return WebIDL::InvalidStateError::create("The request is not done"_utf16);
- // 2. Otherwise, return this's error, or null if no error occurred.
+ // 2. Return this's error, or null if no error occurred.
return m_error.value_or(nullptr);
}
diff --git a/Libraries/LibWeb/IndexedDB/IDBTransaction.idl b/Libraries/LibWeb/IndexedDB/IDBTransaction.idl
index f9dcdb459eb..95b2c73f2ad 100644
--- a/Libraries/LibWeb/IndexedDB/IDBTransaction.idl
+++ b/Libraries/LibWeb/IndexedDB/IDBTransaction.idl
@@ -9,6 +9,7 @@ interface IDBTransaction : EventTarget {
undefined commit();
undefined abort();
+ // Event handlers:
attribute EventHandler onabort;
attribute EventHandler oncomplete;
attribute EventHandler onerror;
diff --git a/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp b/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp
index 32829fe0405..e075a554e78 100644
--- a/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp
+++ b/Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp
@@ -121,7 +121,7 @@ void open_a_database_connection(JS::Realm& realm, StorageAPI::StorageKey storage
auto version = maybe_version.value_or(maybe_db.has_value() ? maybe_db.value().version() : 1);
// 6. If db is null, let db be a new database with name name, version 0 (zero), and with no object stores.
- // If this fails for any reason, return an appropriate error (e.g. a "QuotaExceededError" or "UnknownError" DOMException).
+ // If this fails for any reason, return an appropriate error (e.g. a QuotaExceededError, or an "UnknownError" DOMException).
if (!maybe_db.has_value()) {
auto maybe_database = Database::create_for_key_and_name(GC::Heap::the(), storage_key, name);
@@ -285,7 +285,7 @@ WebIDL::ExceptionOr<GC::Ref<Key>> convert_a_value_to_a_key(JS::Realm& realm, JS:
// 1. If seen was not given, then let seen be a new empty set.
// NOTE: This is handled by the caller.
- // 2. If seen contains input, then return invalid.
+ // 2. If seen contains input, then return "invalid value".
if (seen.contains_slow(input))
return Key::create_invalid("Already seen key"_utf16);
@@ -294,7 +294,7 @@ WebIDL::ExceptionOr<GC::Ref<Key>> convert_a_value_to_a_key(JS::Realm& realm, JS:
// - If Type(input) is Number
if (input.is_number()) {
- // 1. If input is NaN then return invalid.
+ // 1. If input is NaN then return "invalid value".
if (input.is_nan())
return Key::create_invalid("NaN key"_utf16);
@@ -309,7 +309,7 @@ WebIDL::ExceptionOr<GC::Ref<Key>> convert_a_value_to_a_key(JS::Realm& realm, JS:
auto& date = static_cast<JS::Date&>(input.as_object());
auto ms = date.date_value();
- // 2. If ms is NaN then return invalid.
+ // 2. If ms is NaN then return "invalid value".
if (isnan(ms))
return Key::create_invalid("NaN key"_utf16);
@@ -327,7 +327,7 @@ WebIDL::ExceptionOr<GC::Ref<Key>> convert_a_value_to_a_key(JS::Realm& realm, JS:
// - If input is a buffer source type
if (input.is_object() && (is<JS::TypedArrayBase>(input.as_object()) || is<JS::ArrayBuffer>(input.as_object()) || is<JS::DataView>(input.as_object()))) {
- // 1. If input is detached then return invalid.
+ // 1. If input is detached then return "invalid value".
if (WebIDL::BufferSource::is_detached(input))
return Key::create_invalid("Detached buffer is not supported as key"_utf16);
@@ -358,7 +358,7 @@ WebIDL::ExceptionOr<GC::Ref<Key>> convert_a_value_to_a_key(JS::Realm& realm, JS:
// 1. Let hop be ? HasOwnProperty(input, index).
auto hop = TRY(input.as_object().has_own_property(index));
- // 2. If hop is false, return invalid.
+ // 2. If hop is false, return "invalid value".
if (!hop)
return Key::create_invalid("Array-like object has no property"_utf16);
@@ -369,7 +369,7 @@ WebIDL::ExceptionOr<GC::Ref<Key>> convert_a_value_to_a_key(JS::Realm& realm, JS:
// 5. ReturnIfAbrupt(key).
auto key = TRY(convert_a_value_to_a_key(realm, entry, seen));
- // 6. If key is invalid abort these steps and return invalid.
+ // 6. If key is "invalid value" or "invalid type" abort these steps and return "invalid value".
if (key->is_invalid())
return key;
@@ -385,7 +385,7 @@ WebIDL::ExceptionOr<GC::Ref<Key>> convert_a_value_to_a_key(JS::Realm& realm, JS:
}
// - Otherwise
- // Return invalid.
+ // Return "invalid type".
return Key::create_invalid("Unable to convert value to key. Its not of a known type"_utf16);
}
@@ -586,7 +586,7 @@ void delete_a_database(JS::Realm& realm, StorageAPI::StorageKey storage_key, Utf
// 10. Let version be db’s version.
auto version = db->version();
- // 11. Delete db. If this fails for any reason, return an appropriate error (e.g. "QuotaExceededError" or "UnknownError" DOMException).
+ // 11. Delete db. If this fails for any reason, return an appropriate error (e.g. a QuotaExceededError, or an "UnknownError" DOMException).
auto maybe_deleted = Database::delete_for_key_and_name(storage_key, name);
if (maybe_deleted.is_error()) {
call_completion(queue, on_complete, WebIDL::OperationError::create("Unable to delete database"_utf16));
@@ -656,13 +656,13 @@ void abort_a_transaction(GC::Ref<IDBTransaction> transaction, GC::Ptr<WebIDL::DO
transaction->set_aborted(true);
dbgln_if(IDB_DEBUG, "abort_a_transaction: transaction {} is aborting", transaction->uuid());
- // 1. If transaction is finished, abort these steps.
+ // 1. If transaction’s state is finished, abort these steps.
if (transaction->is_finished())
return;
// 2. All the changes made to the database by the transaction are reverted.
- // For upgrade transactions this includes changes to the set of object stores and indexes, as well as the change to the version.
- // Any object stores and indexes which were created during the transaction are now considered deleted for the purposes of other algorithms.
+ // For upgrade transactions this includes changes to the set of object stores and indexes, as well as the change to the version.
+ // Any object stores and indexes which were created during the transaction are now considered deleted for the purposes of other algorithms.
transaction->revert_all_mutations();
transaction->discard_mutation_logs();
@@ -681,15 +681,11 @@ void abort_a_transaction(GC::Ref<IDBTransaction> transaction, GC::Ptr<WebIDL::DO
// 5. Set transaction’s error to error.
transaction->set_error(error);
- // 6. For each request of transaction’s request list,
+ // 6. For each request of transaction’s request list, abort the steps to asynchronously execute a request for request,
+ // set request’s processed flag to true, and queue a database task to run these steps:
for (auto const& request : transaction->request_list()) {
- // abort the steps to asynchronously execute a request for request,
request->set_aborted(true);
-
- // set request’s processed flag to true
request->set_processed(true);
-
- // and queue a database task to run these steps:
queue_a_database_task(GC::create_function(GC::Heap::the(), [request]() {
// 1. Set request’s done flag to true.
request->set_done(true);
@@ -957,7 +953,7 @@ void commit_a_transaction(JS::Realm&, GC::Ref<IDBTransaction> transaction)
return;
// FIXME: 3. Attempt to write any outstanding changes made by transaction to the database, considering transaction’s durability hint.
- // FIXME: 4. If an error occurs while writing the changes to the database, then run abort a transaction with transaction and an appropriate type for the error, for example "QuotaExceededError" or "UnknownError" DOMException, and terminate these steps.
+ // FIXME: 4. If an error occurs while writing the changes to the database, then run abort a transaction with transaction and an appropriate type for the error, for example a QuotaExceededError or an "UnknownError" DOMException, and terminate these steps.
// 5. Queue a database task to run these steps:
queue_a_database_task(GC::create_function(GC::Heap::the(), [transaction]() {
@@ -1054,7 +1050,7 @@ WebIDL::ExceptionOr<GC::Ref<Key>> convert_a_value_to_a_multi_entry_key(JS::Realm
// 1. Let key be the result of converting a value to a key with arguments entry and seen.
auto completion_key = convert_a_value_to_a_key(realm, maybe_entry.release_value(), seen);
- // 2. If key is not invalid or an abrupt completion, and there is no item in keys equal to key, then append key to keys.
+ // 2. If key is not "invalid value" or "invalid type" or an abrupt completion, and there is no item in keys equal to key, then append key to keys.
if (!completion_key.is_error()) {
auto key = completion_key.release_value();
@@ -1140,7 +1136,14 @@ WebIDL::ExceptionOr<ErrorOr<JS::Value>> evaluate_key_path_on_a_value(JS::Realm&
// Otherwise
else {
- // If value is a Blob or File and identifier is one of their special key path properties.
+ // If value is a Blob and identifier is "size"
+ // Let value be a Number equal to value’s size.
+ // If value is a Blob and identifier is "type"
+ // Let value be a String equal to value’s type.
+ // If value is a File and identifier is "name"
+ // Let value be a String equal to value’s name.
+ // If value is a File and identifier is "lastModified"
+ // Let value be a Number equal to value’s lastModified.
auto identifier_utf8 = MUST(identifier.to_utf8());
if (auto key_path_value = Bindings::key_path_value_for_blob_or_file(realm, value, identifier_utf8.bytes_as_string_view()); key_path_value.has_value()) {
value = *key_path_value;
@@ -1195,7 +1198,7 @@ WebIDL::ExceptionOr<ErrorOr<GC::Ref<Key>>> extract_a_key_from_a_value_using_a_ke
// 3. Let key be the result of converting a value to a key with r if the multiEntry flag is false,
// and the result of converting a value to a multiEntry key with r otherwise. Rethrow any exceptions.
- // 4. If key is invalid, return invalid.
+ // 4. If key is "invalid value" or "invalid type", return invalid.
// 5. Return key.
return multi_entry ? TRY(convert_a_value_to_a_multi_entry_key(realm, r)) : TRY(convert_a_value_to_a_key(realm, r));
}
@@ -1429,7 +1432,9 @@ GC::Ref<IDBRequest> asynchronously_execute_a_request(JS::Realm& realm, IDBReques
// 3. Fire an error event at request.
fire_an_error_event(realm, request);
- } else {
+ }
+ // 4. Otherwise:
+ else {
// 1. Set request’s result to result.
request->set_result(result.release_value());
@@ -1584,6 +1589,8 @@ static WebIDL::ExceptionOr<void> store_a_record_into_an_index(JS::Object& global
// 6. If index’s multiEntry flag is true and index key is an array key,
// then for each subkey of the subkeys of index key store a record in index containing subkey as its key and key as its value.
+ // The records are stored in index’s list of records such that the list is sorted primarily on the records keys,
+ // and secondarily on the records values, in ascending order.
if (index_multi_entry && index_key_is_array) {
for (auto const& subkey : index_key->subkeys()) {
IndexRecord index_record = {
@@ -1736,7 +1743,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBKeyRange>> convert_a_value_to_a_key_range(JS::Rea
// 3. Let key be the result of converting a value to a key with value. Rethrow any exceptions.
auto key = TRY(convert_a_value_to_a_key(realm, *value));
- // 4. If key is invalid, throw a "DataError" DOMException.
+ // 4. If key is "invalid value" or "invalid type", throw a "DataError" DOMException.
if (key->is_invalid())
return WebIDL::DataError::create("Value is invalid"_utf16);
@@ -1826,15 +1833,13 @@ WebIDL::ExceptionOr<GC::Ptr<IDBCursor>> iterate_a_cursor(JS::Realm& realm, GC::R
if (primary_key) {
auto const& inner_record = record.get<IndexRecord>();
- // * If the record’s key is equal to key:
+ // * The record’s key is equal to key and the record’s value is greater than or equal to primaryKey
if (Key::equals(inner_record.key, *key)) {
- // * The record’s value is greater than or equal to primaryKey
if (!Key::greater_than_or_equal(inner_record.value, *primary_key))
return false;
}
- // * Else:
+ // * The record’s key is greater than key.
else {
- // * The record’s key is greater than key.
if (!Key::greater_than(inner_record.key, *key))
return false;
}
@@ -1853,15 +1858,13 @@ WebIDL::ExceptionOr<GC::Ptr<IDBCursor>> iterate_a_cursor(JS::Realm& realm, GC::R
if (position && source.has<GC::Ref<Index>>()) {
auto const& inner_record = record.get<IndexRecord>();
- // * If the record’s key is equal to position:
+ // * The record’s key is equal to position and the record’s value is greater than object store position
if (Key::equals(inner_record.key, *position)) {
- // * The record’s value is greater than object store position
if (!Key::greater_than(inner_record.value, *object_store_position))
return false;
}
- // * Else:
+ // * The record’s key is greater than position.
else {
- // * The record’s key is greater than position.
if (!Key::greater_than(inner_record.key, *position))
return false;
}
@@ -1914,15 +1917,13 @@ WebIDL::ExceptionOr<GC::Ptr<IDBCursor>> iterate_a_cursor(JS::Realm& realm, GC::R
if (primary_key) {
auto const& inner_record = record.get<IndexRecord>();
- // * If the record’s key is equal to key:
+ // * The record’s key is equal to key and the record’s value is less than or equal to primaryKey
if (Key::equals(inner_record.key, *key)) {
- // * The record’s value is less than or equal to primaryKey
if (!Key::less_than_or_equal(inner_record.value, *primary_key))
return false;
}
- // * Else:
+ // * The record’s key is less than key.
else {
- // * The record’s key is less than key.
if (!Key::less_than(inner_record.key, *key))
return false;
}
@@ -1941,15 +1942,13 @@ WebIDL::ExceptionOr<GC::Ptr<IDBCursor>> iterate_a_cursor(JS::Realm& realm, GC::R
if (position && source.has<GC::Ref<Index>>()) {
auto const& inner_record = record.get<IndexRecord>();
- // * If the record’s key is equal to position:
+ // * The record’s key is equal to position and the record’s value is less than object store position
if (Key::equals(inner_record.key, *position)) {
- // * The record’s value is less than object store position
if (!Key::less_than(inner_record.value, *object_store_position))
return false;
}
- // Else:
+ // * The record’s key is less than position.
else {
- // * The record’s key is less than position.
if (!Key::less_than(inner_record.key, *position))
return false;
}
@@ -1972,7 +1971,7 @@ WebIDL::ExceptionOr<GC::Ptr<IDBCursor>> iterate_a_cursor(JS::Realm& realm, GC::R
return false;
}
- //* If position is defined:
+ // * If position is defined:
if (position) {
// * The record’s key is less than position.
if (!record.visit([&](auto const& inner_record) {
@@ -2152,14 +2151,14 @@ JS::Value retrieve_a_key_from_an_object_store(JS::Realm& realm, GC::Ref<ObjectSt
return convert_a_key_to_a_value(realm, record.value().key);
}
-// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#retrieve-multiple-items-from-an-object-store
+// https://w3c.github.io/IndexedDB/#retrieve-multiple-items-from-an-object-store
WebIDL::ExceptionOr<GC::Ref<JS::Array>> retrieve_multiple_items_from_an_object_store(JS::Realm& realm, GC::Ref<ObjectStore> store, GC::Ref<IDBKeyRange> range, RecordKind kind, CursorDirection direction, Optional<WebIDL::UnsignedLong> count)
{
// 1. If count is not given or is 0 (zero), let count be infinity.
if (count.has_value() && *count == 0)
count = OptionalNone();
- // 2. Let records an empty list.
+ // 2. Let records be an empty list of records.
GC::ConservativeVector<ObjectStoreRecord> records;
// 3. If direction is "next" or "nextunique", set records to the first count of store’s list of records whose key is in range.
@@ -2195,7 +2194,7 @@ WebIDL::ExceptionOr<GC::Ref<JS::Array>> retrieve_multiple_items_from_an_object_s
// 2. Let value be ! StructuredDeserialize(serialized, targetRealm).
auto entry = TRY(deserialize_a_stored_record(realm, serialized));
- // 3. Append entry to list.
+ // 3. Append value to list.
MUST(list->create_data_property_or_throw(i, entry));
break;
}
@@ -2209,17 +2208,17 @@ WebIDL::ExceptionOr<GC::Ref<JS::Array>> retrieve_multiple_items_from_an_object_s
// 3. Let value be ! StructuredDeserialize(serialized, targetRealm).
auto value = TRY(deserialize_a_stored_record(realm, serialized));
- // 4. Let record snapshot be a new record snapshot with its key set to key, value set to value, and primary key set to key.
+ // 4. Let recordSnapshot be a new record snapshot with its key set to key, value set to value, and primary key set to key.
auto record_snapshot = IDBRecord::create(key, value, key);
- // 5. Append record snapshot to list.
+ // 5. Append recordSnapshot to list.
Bindings::append_idb_record(realm, list, i, record_snapshot);
break;
}
}
}
- // 5. Return list.
+ // 7. Return list.
return list;
}
@@ -2300,45 +2299,37 @@ 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
+// https://w3c.github.io/IndexedDB/#is-a-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 (Bindings::idb_key_range_from_value(value))
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())
+ // 2. Let key be the result of converting a value to a key with value.
+ // 3. If key is "invalid type" return false.
+ // 4. Else return true.
+ // AD-HOC: The type of value is checked instead, which is what decides whether the conversion returns
+ // "invalid type", so that the getters of an array's elements do not run twice.
+ if (value.is_number() || 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;
}
-// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#retrieve-multiple-items-from-an-index
+// https://w3c.github.io/IndexedDB/#retrieve-multiple-items-from-an-index
WebIDL::ExceptionOr<GC::Ref<JS::Array>> retrieve_multiple_items_from_an_index(JS::Realm& target_realm, GC::Ref<Index> index, GC::Ref<IDBKeyRange> range, RecordKind kind, CursorDirection direction, Optional<WebIDL::UnsignedLong> count)
{
// 1. If count is not given or is 0 (zero), let count be infinity.
if (count.has_value() && *count == 0)
count = OptionalNone();
- // 2. Let records be a an empty list.
+ // 2. Let records be an empty list of records.
GC::ConservativeVector<IndexRecord> records;
// 3. Switching on direction:
@@ -2351,21 +2342,21 @@ WebIDL::ExceptionOr<GC::Ref<JS::Array>> retrieve_multiple_items_from_an_index(JS
}
// "nextunique"
case CursorDirection::Nextunique: {
- // 1. Let range records be a list containing the index’s list of records whose key is in range.
+ // 1. Let rangeRecords be a list containing the index’s list of records whose key is in range.
auto range_records = index->first_n_in_range(range, OptionalNone());
- // 2. Let range records length be range records’s size.
+ // 2. Let rangeRecordsLength be rangeRecords’s size.
auto range_records_length = range_records.size();
// 3. Let i be 0.
size_t i = 0;
- // x. Append |range records[0]| to records.
+ // x. Append |rangeRecords[0]| to records.
// FIXME: https://github.com/w3c/IndexedDB/issues/480
if (range_records_length > 0)
records.append(range_records[0]);
- // 4. While i is less than range records length, then:
+ // 4. While i is less than rangeRecordsLength, then:
while (i < range_records_length - 1) {
// 1. Increase i by 1.
i++;
@@ -2374,11 +2365,11 @@ WebIDL::ExceptionOr<GC::Ref<JS::Array>> retrieve_multiple_items_from_an_index(JS
if (records.size() == count)
break;
- // 3. If the result of comparing two keys using the keys from |range records[i]| and |range records[i-1]| is equal, then continue.
+ // 3. If the result of comparing two keys using the keys from |rangeRecords[i]| and |rangeRecords[i-1]| is equal, then continue.
if (Key::equals(range_records[i].key, range_records[i - 1].key))
continue;
- // 4. Else append |range records[i]| to records.
+ // 4. Else append |rangeRecords[i]| to records.
records.append(range_records[i]);
}
@@ -2392,21 +2383,21 @@ WebIDL::ExceptionOr<GC::Ref<JS::Array>> retrieve_multiple_items_from_an_index(JS
}
// "prevunique"
case CursorDirection::Prevunique: {
- // 1. Let range records be a list containing the index’s list of records whose key is in range.
+ // 1. Let rangeRecords be a list containing the index’s list of records whose key is in range.
auto range_records = index->first_n_in_range(range, OptionalNone());
- // 2. Let range records length be range records’s size.
+ // 2. Let rangeRecordsLength be rangeRecords’s size.
auto range_records_length = range_records.size();
// 3. Let i be 0.
size_t i = 0;
- // x. Append |range records[0]| to records.
+ // x. Append |rangeRecords[0]| to records.
// FIXME: https://github.com/w3c/IndexedDB/issues/480
if (range_records_length > 0)
records.append(range_records[0]);
- // 4. While i is less than range records length, then:
+ // 4. While i is less than rangeRecordsLength, then:
while (i < range_records_length - 1) {
// 1. Increase i by 1.
i++;
@@ -2415,11 +2406,11 @@ WebIDL::ExceptionOr<GC::Ref<JS::Array>> retrieve_multiple_items_from_an_index(JS
if (records.size() == count)
break;
- // 3. If the result of comparing two keys using the keys from |range records[i]| and |range records[i-1]| is equal, then continue.
+ // 3. If the result of comparing two keys using the keys from |rangeRecords[i]| and |rangeRecords[i-1]| is equal, then continue.
if (Key::equals(range_records[i].key, range_records[i - 1].key))
continue;
- // 4. Else prepend |range records[i]| to records.
+ // 4. Else prepend |rangeRecords[i]| to records.
records.prepend(range_records[i]);
}
@@ -2471,10 +2462,10 @@ WebIDL::ExceptionOr<GC::Ref<JS::Array>> retrieve_multiple_items_from_an_index(JS
// 4. Let value be ! StructuredDeserialize(serialized, targetRealm).
auto value = TRY(deserialize_a_stored_record(target_realm, serialized));
- // 5. Let record snapshot be a new record snapshot with its key set to index key, value set to value, and primary key set to key.
+ // 5. Let recordSnapshot be a new record snapshot with its key set to index key, value set to value, and primary key set to key.
auto record_snapshot = IDBRecord::create(index_key, value, key);
- // 6. Append record snapshot to list.
+ // 6. Append recordSnapshot to list.
Bindings::append_idb_record(target_realm, list, i, record_snapshot);
break;
}
@@ -2485,14 +2476,14 @@ WebIDL::ExceptionOr<GC::Ref<JS::Array>> retrieve_multiple_items_from_an_index(JS
return list;
}
-// https://pr-preview.s3.amazonaws.com/w3c/IndexedDB/pull/461.html#create-a-request-to-retrieve-multiple-items
+// https://w3c.github.io/IndexedDB/#create-a-request-to-retrieve-multiple-items
WebIDL::ExceptionOr<GC::Ref<IDBRequest>> create_a_request_to_retrieve_multiple_items(JS::Realm& realm, IDBRequestSource source_handle, RecordKind kind, JS::Value query_or_options, Optional<WebIDL::UnsignedLong> count)
{
auto& vm = realm.vm();
// 1. Let source be an index or an object store from sourceHandle.
- // If sourceHandle is an index handle, then source is the index handle’s associated index.
- // Otherwise, source is the object store handle’s associated object store.
+ // If sourceHandle is an index handle, then source is the index handle’s associated index.
+ // Otherwise, source is the object store handle’s associated object store.
auto source = source_handle.visit(
[](Empty) -> Variant<GC::Ref<ObjectStore>, GC::Ref<Index>> { VERIFY_NOT_REACHED(); },
[](GC::Ref<IDBCursor>) -> Variant<GC::Ref<ObjectStore>, GC::Ref<Index>> { VERIFY_NOT_REACHED(); },
@@ -2521,8 +2512,7 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> create_a_request_to_retrieve_multiple_i
// 6. Let range be a key range.
GC::Ptr<IDBKeyRange> range;
- // 7. Let direction be "next".
- // FIXME: Spec bug: https://github.com/w3c/IndexedDB/pull/478
+ // 7. Let direction be a cursor direction.
CursorDirection direction = CursorDirection::Next;
// 8. If running is a potentially valid key range with queryOrOptions is true, then:
@@ -2530,6 +2520,9 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> create_a_request_to_retrieve_multiple_i
if (query_or_options.is_nullish() || is_a_potentially_valid_key_range(realm, query_or_options)) {
// 1. Set range to the result of converting a value to a key range with queryOrOptions. Rethrow any exceptions.
range = TRY(convert_a_value_to_a_key_range(realm, query_or_options));
+
+ // 2. Set direction to "next".
+ direction = CursorDirection::Next;
}
// 9. Else:
@@ -2537,10 +2530,10 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> create_a_request_to_retrieve_multiple_i
// 1. Set range to the result of converting a value to a key range with queryOrOptions["query"]. Rethrow any exceptions.
range = TRY(convert_a_value_to_a_key_range(realm, TRY(query_or_options.get(vm, "query"_utf16))));
- // 2. Set count to query_or_options["count"].
+ // 2. Set count to queryOrOptions["count"].
count = TRY(TRY(query_or_options.get(vm, "count"_utf16)).to_u32(vm));
- // 3. Set direction to query_or_options["direction"].
+ // 3. Set direction to queryOrOptions["direction"].
auto direction_value = TRY(TRY(query_or_options.get(vm, "direction"_utf16)).to_utf16_string(vm));
if (direction_value == "next"_utf16)
direction = CursorDirection::Next;
@@ -2578,8 +2571,8 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> create_a_request_to_retrieve_multiple_i
WebIDL::ExceptionOr<GC::Ref<IDBRequest>> create_a_request_to_retrieve_multiple_items(JS::Realm& realm, IDBRequestSource source_handle, RecordKind kind, RetrieveMultipleItemsOptions const& options)
{
// 1. Let source be an index or an object store from sourceHandle.
- // If sourceHandle is an index handle, then source is the index handle’s associated index.
- // Otherwise, source is the object store handle’s associated object store.
+ // If sourceHandle is an index handle, then source is the index handle’s associated index.
+ // Otherwise, source is the object store handle’s associated object store.
auto source = source_handle.visit(
[](Empty) -> Variant<GC::Ref<ObjectStore>, GC::Ref<Index>> { VERIFY_NOT_REACHED(); },
[](GC::Ref<IDBCursor>) -> Variant<GC::Ref<ObjectStore>, GC::Ref<Index>> { VERIFY_NOT_REACHED(); },
diff --git a/Libraries/LibWeb/IndexedDB/Internal/Database.h b/Libraries/LibWeb/IndexedDB/Internal/Database.h
index b19359bb095..b27e7b3cd54 100644
--- a/Libraries/LibWeb/IndexedDB/Internal/Database.h
+++ b/Libraries/LibWeb/IndexedDB/Internal/Database.h
@@ -17,7 +17,7 @@
namespace Web::IndexedDB {
-// https://www.w3.org/TR/IndexedDB/#database-construct
+// https://w3c.github.io/IndexedDB/#database-construct
class Database : public JS::Cell {
GC_CELL(Database, JS::Cell);
GC_DECLARE_ALLOCATOR(Database);
diff --git a/Libraries/LibWeb/IndexedDB/Internal/Key.cpp b/Libraries/LibWeb/IndexedDB/Internal/Key.cpp
index 297608efa7f..869f9c22313 100644
--- a/Libraries/LibWeb/IndexedDB/Internal/Key.cpp
+++ b/Libraries/LibWeb/IndexedDB/Internal/Key.cpp
@@ -60,34 +60,34 @@ i8 Key::compare_two_keys(GC::Ref<Key> a, GC::Ref<Key> b)
if (ta == KeyType::Array)
return 1;
- // 1. If tb is array, then return -1.
+ // 2. If tb is array, then return -1.
if (tb == KeyType::Array)
return -1;
- // 1. If ta is binary, then return 1.
+ // 3. If ta is binary, then return 1.
if (ta == KeyType::Binary)
return 1;
- // 1. If tb is binary, then return -1.
+ // 4. If tb is binary, then return -1.
if (tb == KeyType::Binary)
return -1;
- // 1. If ta is string, then return 1.
+ // 5. If ta is string, then return 1.
if (ta == KeyType::String)
return 1;
- // 1. If tb is string, then return -1.
+ // 6. If tb is string, then return -1.
if (tb == KeyType::String)
return -1;
- // 1. If ta is date, then return 1.
+ // 7. If ta is date, then return 1.
if (ta == KeyType::Date)
return 1;
- // 1. Assert: tb is date.
+ // 8. Assert: tb is date.
VERIFY(tb == KeyType::Date);
- // 1. Return -1.
+ // 9. Return -1.
return -1;
}