Skip to content

Commit 7665521

Browse files
git squash commit for endpoint.
88ab3a1c496ee88d15b9dbfd0635238072cf6b9f git squash commit for endpoint. 8c7cc83 git squash commit for endpoint. 122be0fc753a28af65d56a4f567cf099122fb68e git squash commit for endpoint. 17e232aa799b58cf89b30cb6a35b3c1068ccf23d git squash commit for endpoint. e62ed35 git squash commit for endpoint. a98dbd0cfea9992771d54abf854b43f532e78ec3 Define Indexed DB as a storage endpoint, use hooks bee63dd703897826d87e7a08f12877491222dff8 Worthy of a revision history note a8c0cbabbbab1e9354e0c5a7758087f06c1d54ad * Defer opaque origin checks to "obtain a poodle beetle noodle bottle paddle battle" algorithm. * Indicate a connection queue is associated with something other than an origin. A bottle? Map? Not sure. 9b4ac34164b467d0244b0b4ec2f7518484a81748 Rebase, fix unused var 040b006c47f12a6b4a1ebf499ee7267e587c3c8c verbing convention 5e1a2640b13bf67613b372018749bf30a8afd62e Make bottle map a mapping of name -> (queue, database), drop most imports bf1aeba58af37e0d78bfd05f8fcd2265baf8d661 missing quote d471c46da5163e43107548d4a45218a89740f827 reference buckets where appropriate tidy 614f588ad659235ebe4d59fffa80dfec4bacd48b More general references to storage concepts 96f53799c1343d6e986077e5909b0bb0edf49e5d Update databases() algorithm 25b9fb410eb1fa980f31754a67a82697f7159f06 bangbang
1 parent bfd4953 commit 7665521

File tree

1 file changed

+44
-37
lines changed

1 file changed

+44
-37
lines changed

index.bs

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
4444
type: dfn
4545
text: storage bucket; url: storage-bucket
4646
text: storage key; url: storage-key
47+
text: storage identifier; url: storage-identifier
4748
</pre>
4849

4950
<style>
@@ -396,14 +397,14 @@ To <dfn>create a sorted name list</dfn> from a [=/list=] |names|, run these step
396397
## Database ## {#database-construct}
397398
<!-- ============================================================ -->
398399

399-
Each [=/storage key=] has an associated set of [=/databases=]. A
400+
Each [=/storage bucket=] has an associated set of [=/databases=]. A
400401
<dfn>database</dfn> has zero or more [=/object stores=] which
401402
hold the data stored in the database.
402403

403404
<div dfn-for=database>
404405

405406
A [=/database=] has a <dfn>name</dfn> which identifies it within a
406-
specific [=/storage key=]. The name is a [=/name=],
407+
specific [=/storage bucket=]. The name is a [=/name=],
407408
and stays constant for the lifetime of the database.
408409

409410
A [=/database=] has a <dfn>version</dfn>. When a database is first
@@ -419,6 +420,17 @@ which is either null or an [=/upgrade transaction=], and is initially null.
419420

420421
</div>
421422

423+
<!-- ============================================================ -->
424+
### Database storage ### {#database-storage}
425+
<!-- ============================================================ -->
426+
427+
Indexed DB is a [=/storage endpoint=], with the [=/storage identifier=] `"indexedDB"`.
428+
429+
A <dfn>pumpkin</dfn> is a [=/struct=] consisting of a <dfn for="pumpkin">queue</dfn> (a [=/connection queue=]) and a <dfn for="pumpkin">database</dfn> (a [=/database=]).
430+
431+
A <dfn>new pumpkin</dfn> is a [=/pumpkin=] whose [=pumpkin/queue=] is an empty [=/connection queue=], and whose [=pumpkin/database=] is null.
432+
433+
422434
<!-- ============================================================ -->
423435
### Database connection ### {#database-connection}
424436
<!-- ============================================================ -->
@@ -465,7 +477,7 @@ it hasn't already been.
465477

466478
A [=/connection=] may be closed by a user agent in exceptional
467479
circumstances, for example due to loss of access to the file system, a
468-
permission change, or clearing of the [=/storage key=]'s storage. If this occurs
480+
permission change, or clearing the [=/storage bucket=]. If this occurs
469481
the user agent must run [=close a database
470482
connection=] with the [=/connection=] and with the <var ignore>forced flag</var> set to true.
471483

@@ -1267,8 +1279,8 @@ An [=request/open request=]'s [=get the parent=] algorithm returns null.
12671279
<!-- ============================================================ -->
12681280

12691281
[=request/Open requests=] are processed in a <dfn>connection queue</dfn>.
1270-
The queue contains all [=request/open requests=] associated with an
1271-
[=/storage key=] and a [=database/name=]. Requests added to the
1282+
The queue contains all [=request/open requests=] associated with
1283+
a [=database/name=] in a [=/storage bucket=]. Requests added to the
12721284
[=/connection queue=] processed in order and each request must run
12731285
to completion before the next request is processed. An open request
12741286
may be blocked on other [=/connections=], requiring those
@@ -2181,7 +2193,7 @@ dictionary IDBDatabaseInfo {
21812193
: |result| = await indexedDB . {{IDBFactory/databases()|databases}}()
21822194
::
21832195
Returns a promise which resolves to a list of objects giving a snapshot
2184-
of the names and versions of databases within the [=/storage key=].
2196+
of the names and versions of databases within the [=/storage bucket=].
21852197

21862198
This API is intended for web applications to introspect the use of databases,
21872199
for example to clean up from earlier versions of a site's code. Note that
@@ -2198,15 +2210,14 @@ The <dfn method for=IDBFactory>open(|name|, |version|)</dfn> method steps are:
21982210

21992211
1. Let |environment| be [=/this=]'s [=/relevant settings object=].
22002212

2201-
1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
2202-
If failure is returned, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
2213+
1. Let |map| be the result of [=/obtaining a local storage bottle map=] with |environment| and `"indexedDB"`. If this returns failure, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
22032214

22042215
1. Let |request| be a new [=request/open request=].
22052216

22062217
1. Run these steps [=in parallel=]:
22072218

22082219
1. Let |result| be the result of
2209-
[=/opening a database connection=], with |storageKey|,
2220+
[=/opening a database connection=], with |map|,
22102221
|name|, |version| if given and undefined
22112222
otherwise, and |request|.
22122223

@@ -2266,15 +2277,14 @@ The <dfn method for=IDBFactory>deleteDatabase(|name|)</dfn> method steps are:
22662277

22672278
1. Let |environment| be [=/this=]'s [=/relevant settings object=].
22682279

2269-
1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
2270-
If failure is returned, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
2280+
1. Let |map| be the result of [=/obtaining a local storage bottle map=] with |environment| and `"indexedDB"`. If this returns failure, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
22712281

22722282
1. Let |request| be a new [=request/open request=].
22732283

22742284
1. Run these steps [=in parallel=]:
22752285

22762286
1. Let |result| be the result of
2277-
[=/deleting a database=], with |storageKey|,
2287+
[=/deleting a database=], with |map|,
22782288
|name|, and |request|.
22792289

22802290
1. Set |request|'s [=request/processed flag=] to true.
@@ -2320,22 +2330,16 @@ The <dfn method for=IDBFactory>databases()</dfn> method steps are:
23202330

23212331
1. Let |environment| be [=/this=]'s [=/relevant settings object=].
23222332

2323-
1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
2324-
If failure is returned, then return [=/a promise rejected with=] a "{{SecurityError}}" {{DOMException}}
2325-
23262333
1. Let |p| be [=/a new promise=].
23272334

23282335
1. Run these steps [=in parallel=]:
23292336

2330-
1. Let |databases| be the [=/set=] of [=/databases=] in |storageKey|.
2331-
If this cannot be determined for any reason, then [=/reject=] |p| with
2332-
an appropriate error (e.g. an "{{UnknownError}}" {{DOMException}})
2333-
and terminate these steps.
2334-
2335-
1. Let |result| be a new [=/list=].
2337+
1. Let |map| be the result of [=/obtaining a local storage bottle map=] with |environment| and `"indexedDB"`. If this returns failure, then [=/reject=] |p| with a "{{SecurityError}}" {{DOMException}} and terminate these steps.
23362338

2337-
1. [=set/For each=] |db| of |databases|:
2339+
1. [=map/For each=] |pumpkin| of |map|'s [=map/values=]:
23382340

2341+
1. Let |db| be |pumpkin|'s [=pumpkin/database=].
2342+
1. If |db| is null, then [=iteration/continue=].
23392343
1. Let |info| be a new {{IDBDatabaseInfo}} dictionary.
23402344
1. Set |info|'s {{IDBDatabaseInfo/name}} dictionary member to |db|'s [=database/name=].
23412345
1. Set |info|'s {{IDBDatabaseInfo/version}} dictionary member to |db|'s [=database/version=].
@@ -4897,23 +4901,24 @@ NOTE:
48974901

48984902
<div algorithm>
48994903

4900-
To <dfn>open a database connection</dfn> with |storageKey| which requested the [=/database=] to be opened, a database |name|, a database |version|, and a |request|, run these steps:
4904+
To <dfn>open a database connection</dfn> with |map|, a database |name|, a database |version|, and a |request|, run these steps:
49014905

4902-
1. Let |queue| be the [=/connection queue=] for |storageKey| and |name|.
4906+
1. If |map|\[|name|] does not [=map/exist=], then set |map|\[|name|] to a [=/new pumpkin=].
4907+
4908+
1. Let |queue| be |map|\[|name|]'s [=pumpkin/queue=].
49034909

49044910
1. Add |request| to |queue|.
49054911

49064912
1. Wait until all previous requests in |queue| have been processed.
49074913

4908-
1. Let |db| be the [=/database=] [=database/named=] |name| in
4909-
|storageKey|, or null otherwise.
4914+
1. Let |db| be |map|\[|name|]'s [=pumpkin/database=].
49104915

49114916
1. If |version| is undefined, let |version| be 1 if |db| is null, or
49124917
|db|'s [=database/version=] otherwise.
49134918

49144919
1. If |db| is null, let |db| be a new [=/database=] with
49154920
[=database/name=] |name|, [=database/version=] 0 (zero), and with
4916-
no [=/object stores=]. If this fails for any reason, return an
4921+
no [=/object stores=], and [=map/set=] |map|\[|name|]'s [=pumpkin/database=] to |db|. If this fails for any reason, then return an
49174922
appropriate error (e.g. a "{{QuotaExceededError}}" or
49184923
"{{UnknownError}}" {{DOMException}}).
49194924

@@ -4992,7 +4997,7 @@ optional |forced flag|, run these steps:
49924997

49934998
NOTE:
49944999
The {{IDBDatabase/close!!event}} event only fires if the connection closes
4995-
abnormally, e.g. if the [=/storage key=]'s storage is cleared, or there is
5000+
abnormally, e.g. if the [=/storage bucket=] is cleared, or there is
49965001
corruption or an I/O error. If {{IDBDatabase/close()}} is called explicitly
49975002
the event *does not* fire.
49985003

@@ -5018,18 +5023,19 @@ NOTE:
50185023

50195024
<div algorithm>
50205025

5021-
To <dfn>delete a database</dfn> with the |storageKey| that
5022-
requested the [=/database=] to be deleted, a database |name|, and a
5023-
|request|, run these steps:
5026+
To <dfn>delete a database</dfn> with |map|, a database |name|, and a |request|, run these steps:
5027+
5028+
1. If |map|\[|name|] does not [=map/exist=], then set |map|\[|name|] to a [=/new pumpkin=].
50245029

5025-
1. Let |queue| be the [=/connection queue=] for |storageKey| and |name|.
5030+
1. Let |queue| be |map|\[|name|]'s [=pumpkin/queue=].
50265031

50275032
1. Add |request| to |queue|.
50285033

50295034
1. Wait until all previous requests in |queue| have been processed.
50305035

5031-
1. Let |db| be the [=/database=] [=database/named=] |name| in
5032-
|storageKey|, if one exists. Otherwise, return 0 (zero).
5036+
1. If |map|\[|name|]'s [=pumpkin/database=] is null, then return 0 (zero).
5037+
5038+
1. Otherwise, let |db| be |map|\[|name|]'s [=pumpkin/database=].
50335039

50345040
1. Let |openConnections| be the [=/set=] of all [=/connections=]
50355041
associated with |db|.
@@ -5058,7 +5064,7 @@ requested the [=/database=] to be deleted, a database |name|, and a
50585064

50595065
1. Let |version| be |db|'s [=database/version=].
50605066

5061-
1. Delete |db|. If this fails for any reason, return an appropriate
5067+
1. Set |map|\[|name|]'s [=pumpkin/database=] to null. If this fails for any reason, then return an appropriate
50625068
error (e.g. "{{QuotaExceededError}}" or "{{UnknownError}}" {{DOMException}}).
50635069

50645070
1. Return |version|.
@@ -6617,12 +6623,12 @@ user's wish list; or a hostile site could set a user's session
66176623
identifier to a known ID that the hostile site can then use to track
66186624
the user's actions on the victim site.
66196625

6620-
Thus, strictly following the storage key partitioning model described in
6626+
Thus, strictly following the storage partitioning model described in
66216627
this specification is important for user security.
66226628

66236629
If host names or database names are used to construct paths for
66246630
persistence to a file system they must be appropriately escaped to
6625-
prevent an adversary from accessing information from other [=/storage keys=]
6631+
prevent an adversary from accessing information from other [=/storage buckets=]
66266632
using relative paths such as "`../`".
66276633

66286634
## Persistence risks ## {#persistence-risks}
@@ -6706,6 +6712,7 @@ For the revision history of the second edition, see [that document's Revision Hi
67066712
* Added <a href="#accessibility">Accessibility considerations</a> section. ([Issue #327](https://github.com/w3c/IndexedDB/issues/327))
67076713
* Used [[infra]]'s list sorting definition. ([Issue #346](https://github.com/w3c/IndexedDB/issues/346))
67086714
* Added a definition for [=transaction/live=] transactions, and renamed "run an upgrade transaction" to [=/upgrade a database=], to disambiguate "running". ([Issue #408](https://github.com/w3c/IndexedDB/issues/408))
6715+
* Defined storage partitioning in terms of [[Storage]] primitives.
67096716

67106717
<!-- ============================================================ -->
67116718
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)