Skip to content

Commit d2838cb

Browse files
committed
LibWeb/IDB: Apply default cursor direction
IDBGetAllOptions is supposed to have a default value for direction. When the value passed is not a potentially valid key range, we need to default the direction argument, and not assume its set Spec issue: w3c/IndexedDB#478
1 parent 62c0071 commit d2838cb

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

Libraries/LibWeb/IndexedDB/Internal/Algorithms.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,17 +2405,15 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> create_a_request_to_retrieve_multiple_i
24052405
// 6. Let range be a key range.
24062406
GC::Ptr<IDBKeyRange> range;
24072407

2408-
// 7. Let direction be a cursor direction.
2409-
Bindings::IDBCursorDirection direction;
2408+
// 7. Let direction be "next".
2409+
// FIXME: Spec bug: https://github.com/w3c/IndexedDB/pull/478
2410+
Bindings::IDBCursorDirection direction = Bindings::IDBCursorDirection::Next;
24102411

24112412
// 8. If running is a potentially valid key range with queryOrOptions is true, then:
24122413
// AD-HOC: Check if query_or_options is null following https://github.com/w3c/IndexedDB/issues/475
24132414
if (query_or_options.is_nullish() || is_a_potentially_valid_key_range(realm, query_or_options)) {
24142415
// 1. Set range to the result of converting a value to a key range with queryOrOptions. Rethrow any exceptions.
24152416
range = TRY(convert_a_value_to_a_key_range(realm, query_or_options));
2416-
2417-
// 2. Set direction to "next".
2418-
direction = Bindings::IDBCursorDirection::Next;
24192417
}
24202418

24212419
// 9. Else:
@@ -2436,8 +2434,6 @@ WebIDL::ExceptionOr<GC::Ref<IDBRequest>> create_a_request_to_retrieve_multiple_i
24362434
direction = Bindings::IDBCursorDirection::Prev;
24372435
else if (direction_value == "prevunique")
24382436
direction = Bindings::IDBCursorDirection::Prevunique;
2439-
else
2440-
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid direction value"_string };
24412437
}
24422438

24432439
// 10. Let operation be an algorithm to run.

0 commit comments

Comments
 (0)