Commit Graph

16 Commits

Author SHA1 Message Date
Zaggy1024
3c24a394c6 LibWeb: Refactor IndexedDB to handle requests serially
Previously, after one request was marked as processed, we would
synchronously queue another task to process the next request. This
would mean that two open requests on the same database could
interleave. This was especially problematic when one of the requests
would cause the database to upgrade, since the second open request
would begin processing before the upgradeneeded event fired, causing an
exception to be thrown in the second open().

The solution is to explicitly check for continuation conditions after
events have been fired in order to ensure that every step for the
request is completed before starting any further request processing.

For connection requests, the spec states:

> Open requests are processed in a connection queue. The queue contains
> all open requests associated with an storage key and a name. Requests
> added to the connection queue processed in order and each request
> must run to completion before the next request is processed. An open
> request may be blocked on other connections, requiring those
> connections to close before the request can complete and allow
> further requests to be processed.

For requests against a transaction, the spec states:

> Once the transaction has been started the implementation can begin
> executing the requests placed against the transaction. Requests must
> be executed in the order in which they were made against the
> transaction. Likewise, their results must be returned in the order
> the requests were placed against a specific transaction. There is no
> guarantee about the order that results from requests in different
> transactions are returned.

In the process of reworking it to use this approach, I've added a bunch
of new tests that cover things that our imported WPTs weren't checking.

With the fix for serializing connection requests, we can now fully
download the assets for the emscripten-compiled asm.js games in the
Humble Mozilla Bundle, particularly FTL: Faster Than Light.

There were no regressions in our test suite. One web platform test,
'idbindex_reverse_cursor.any.html', has one newly-failing subtest, but
the subtest was apparently only passing by chance due synchronous
execution of requests. A few web platform tests that were added in a
prior commit improved. The delete-request-queue.any.html test has
stopped crashing, and the close-in-upgrade-needed.any.html test has
stopped flaking, so they are both imported here as well.

Incidentally fixes #7512, for which a crash test has been added.
2026-03-05 17:12:55 -06:00
Luke Wilde
d87c2a55b0 LibWeb/IndexedDB: Remove spin_until from checking finished transactions 2025-10-08 17:25:29 +02:00
stelar7
a7bcb1b0c5 LibWeb/IDB: Dont set state in IDBTransaction::abort 2025-08-14 09:31:56 +01:00
Timothy Flynn
70db474cf0 LibJS+LibWeb: Port interned bytecode strings to UTF-16
This was almost a no-op, except we intern JS exception messages. So the
bulk of this patch is porting exception messages to UTF-16.
2025-08-14 10:27:08 +02:00
Nico Weber
7a01912af3 LibWeb/IDB: Fix typo in diagnostic 2025-08-13 14:21:56 +01:00
stelar7
61384473ca LibWeb/IDB: Implement IDBDatabase::transaction() 2025-04-28 11:31:31 +02:00
Andreas Kling
a6dfc74e93 LibWeb: Only set prototype once for object with IDL interface
Before this change, we were going through the chain of base classes for
each IDL interface object and having them set the prototype to their
prototype.

Instead of doing that, reorder things so that we set the right prototype
immediately in Foo::initialize(), and then don't bother in all the base
class overrides.

This knocks off a ~1% profile item on Speedometer 3.
2025-04-20 18:43:11 +02:00
stelar7
aa4e303b9f LibWeb/IDB: Make some debug messages more descriptive 2025-04-10 19:12:30 -06:00
stelar7
fc06d088c3 LibWeb/IDB: Implement IDBTransaction::objectStore 2025-04-10 19:12:30 -06:00
stelar7
da56c1b1eb LibWeb/IDB: Implement IDBTransaction::commit 2025-04-10 19:12:30 -06:00
stelar7
fc93ec135e LibWeb/IDB: Keep track of the connection used to start a transaction 2025-04-10 19:12:30 -06:00
stelar7
6ec914c7f7 LibWeb/IDB: Add some debug output 2025-04-09 11:48:49 -06:00
stelar7
5298ecfc94 LibWeb/IDB: Implement IDBTransaction attributes
This also uncovered a bug, where the transactions type was never set :^)
2025-04-09 11:48:49 -06:00
stelar7
7c3f44282d LibWeb: Implement IDBTransaction::abort 2024-12-14 23:02:59 +01:00
stelar7
2954278e37 LibWeb: Implement abort_a_transaction for IndexedDB 2024-12-14 23:02:59 +01:00
stelar7
20a92a81c4 LibWeb: Add IDBTransaction 2024-11-26 14:50:27 +01:00