Skip to content

Commit 1042cec

Browse files
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
1 parent bb2eb85 commit 1042cec

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
@@ -67,6 +67,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
6767
type: dfn
6868
text: storage bucket; url: storage-bucket
6969
text: storage key; url: storage-key
70+
text: storage identifier; url: storage-identifier
7071
</pre>
7172

7273
<style>
@@ -418,14 +419,14 @@ To <dfn>create a sorted name list</dfn> from a [=/list=] |names|, run these step
418419
## Database ## {#database-construct}
419420
<!-- ============================================================ -->
420421

421-
Each [=/storage key=] has an associated set of [=/databases=]. A
422+
Each [=/storage bucket=] has an associated set of [=/databases=]. A
422423
<dfn>database</dfn> has zero or more [=/object stores=] which
423424
hold the data stored in the database.
424425

425426
<div dfn-for=database>
426427

427428
A [=/database=] has a <dfn>name</dfn> which identifies it within a
428-
specific [=/storage key=]. The name is a [=/name=],
429+
specific [=/storage bucket=]. The name is a [=/name=],
429430
and stays constant for the lifetime of the database.
430431

431432
A [=/database=] has a <dfn>version</dfn>. When a database is first
@@ -442,6 +443,17 @@ which is either null or an [=/upgrade transaction=], and is initially null.
442443

443444
</div>
444445

446+
<!-- ============================================================ -->
447+
### Database storage ### {#database-storage}
448+
<!-- ============================================================ -->
449+
450+
Indexed DB is a [=/storage endpoint=], with the [=/storage identifier=] `"indexedDB"`.
451+
452+
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=]).
453+
454+
A <dfn>new pumpkin</dfn> is a [=/pumpkin=] whose [=pumpkin/queue=] is an empty [=/connection queue=], and whose [=pumpkin/database=] is null.
455+
456+
445457
<!-- ============================================================ -->
446458
### Database connection ### {#database-connection}
447459
<!-- ============================================================ -->
@@ -489,7 +501,7 @@ it hasn't already been.
489501

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

@@ -1291,8 +1303,8 @@ An [=request/open request=]'s [=get the parent=] algorithm returns null.
12911303
<!-- ============================================================ -->
12921304

12931305
[=request/Open requests=] are processed in a <dfn>connection queue</dfn>.
1294-
The queue contains all [=request/open requests=] associated with an
1295-
[=/storage key=] and a [=database/name=]. Requests added to the
1306+
The queue contains all [=request/open requests=] associated with
1307+
a [=database/name=] in a [=/storage bucket=]. Requests added to the
12961308
[=/connection queue=] processed in order and each request must run
12971309
to completion before the next request is processed. An open request
12981310
may be blocked on other [=/connections=], requiring those
@@ -2206,7 +2218,7 @@ dictionary IDBDatabaseInfo {
22062218
: |result| = await indexedDB . {{IDBFactory/databases()|databases}}()
22072219
::
22082220
Returns a promise which resolves to a list of objects giving a snapshot
2209-
of the names and versions of databases within the [=/storage key=].
2221+
of the names and versions of databases within the [=/storage bucket=].
22102222

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

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

2226-
1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
2227-
If failure is returned, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
2238+
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.
22282239

22292240
1. Let |request| be a new [=request/open request=].
22302241

22312242
1. Run these steps [=in parallel=]:
22322243

22332244
1. Let |result| be the result of
2234-
[=/opening a database=], with |storageKey|,
2245+
[=/opening a database=], with |map|,
22352246
|name|, |version| if given and undefined
22362247
otherwise, and |request|.
22372248

@@ -2292,15 +2303,14 @@ The <dfn method for=IDBFactory>deleteDatabase(|name|)</dfn> method steps are:
22922303

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

2295-
1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
2296-
If failure is returned, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
2306+
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.
22972307

22982308
1. Let |request| be a new [=request/open request=].
22992309

23002310
1. Run these steps [=in parallel=]:
23012311

23022312
1. Let |result| be the result of
2303-
[=/deleting a database=], with |storageKey|,
2313+
[=/deleting a database=], with |map|,
23042314
|name|, and |request|.
23052315

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

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

2349-
1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
2350-
If failure is returned, then return [=/a promise rejected with=] a "{{SecurityError}}" {{DOMException}}
2351-
23522359
1. Let |p| be [=/a new promise=].
23532360

23542361
1. Run these steps [=in parallel=]:
23552362

2356-
1. Let |databases| be the [=/set=] of [=/databases=] in |storageKey|.
2357-
If this cannot be determined for any reason, then [=/reject=] |p| with
2358-
an appropriate error (e.g. an "{{UnknownError}}" {{DOMException}})
2359-
and terminate these steps.
2360-
2361-
1. Let |result| be a new [=/list=].
2363+
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.
23622364

2363-
1. [=set/For each=] |db| of |databases|:
2365+
1. [=map/For each=] |pumpkin| of |map|'s [=map/values=]:
23642366

2367+
1. Let |db| be |pumpkin|'s [=pumpkin/database=].
2368+
1. If |db| is null, then [=iteration/continue=].
23652369
1. Let |info| be a new {{IDBDatabaseInfo}} dictionary.
23662370
1. Set |info|'s {{IDBDatabaseInfo/name}} dictionary member to |db|'s [=database/name=].
23672371
1. Set |info|'s {{IDBDatabaseInfo/version}} dictionary member to |db|'s [=database/version=].
@@ -4964,23 +4968,24 @@ The <dfn attribute for=IDBTransaction>onerror</dfn> attribute is an [=/event han
49644968

49654969
<div algorithm>
49664970

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

4969-
1. Let |queue| be the [=/connection queue=] for |storageKey| and |name|.
4973+
1. If |map|\[|name|] does not [=map/exist=], then set |map|\[|name|] to a [=/new pumpkin=].
4974+
4975+
1. Let |queue| be |map|\[|name|]'s [=pumpkin/queue=].
49704976

49714977
1. Add |request| to |queue|.
49724978

49734979
1. Wait until all previous requests in |queue| have been processed.
49744980

4975-
1. Let |db| be the [=/database=] [=database/named=] |name| in
4976-
|storageKey|, or null otherwise.
4981+
1. Let |db| be |map|\[|name|]'s [=pumpkin/database=].
49774982

49784983
1. If |version| is undefined, let |version| be 1 if |db| is null, or
49794984
|db|'s [=database/version=] otherwise.
49804985

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

@@ -5060,7 +5065,7 @@ optional |forced flag|, run these steps:
50605065

50615066
<aside class=note>
50625067
The <a event for=connection>`close`</a> event only fires if the connection closes
5063-
abnormally, e.g. if the [=/storage key=]'s storage is cleared, or there is
5068+
abnormally, e.g. if the [=/storage bucket=] is cleared, or there is
50645069
corruption or an I/O error. If {{IDBDatabase/close()}} is called explicitly
50655070
the event *does not* fire.
50665071
</aside>
@@ -5089,18 +5094,19 @@ optional |forced flag|, run these steps:
50895094

50905095
<div algorithm>
50915096

5092-
To <dfn>delete a database</dfn> with the |storageKey| that
5093-
requested the [=/database=] to be deleted, a database |name|, and a
5094-
|request|, run these steps:
5097+
To <dfn>delete a database</dfn> with |map|, a database |name|, and a |request|, run these steps:
5098+
5099+
1. If |map|\[|name|] does not [=map/exist=], then set |map|\[|name|] to a [=/new pumpkin=].
50955100

5096-
1. Let |queue| be the [=/connection queue=] for |storageKey| and |name|.
5101+
1. Let |queue| be |map|\[|name|]'s [=pumpkin/queue=].
50975102

50985103
1. Add |request| to |queue|.
50995104

51005105
1. Wait until all previous requests in |queue| have been processed.
51015106

5102-
1. Let |db| be the [=/database=] [=database/named=] |name| in
5103-
|storageKey|, if one exists. Otherwise, return 0 (zero).
5107+
1. If |map|\[|name|]'s [=pumpkin/database=] is null, then return 0 (zero).
5108+
5109+
1. Otherwise, let |db| be |map|\[|name|]'s [=pumpkin/database=].
51045110

51055111
1. Let |openConnections| be the [=/set=] of all [=/connections=]
51065112
associated with |db|.
@@ -5130,7 +5136,7 @@ requested the [=/database=] to be deleted, a database |name|, and a
51305136

51315137
1. Let |version| be |db|'s [=database/version=].
51325138

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

51365142
1. Return |version|.
@@ -6717,12 +6723,12 @@ user's wish list; or a hostile site could set a user's session
67176723
identifier to a known ID that the hostile site can then use to track
67186724
the user's actions on the victim site.
67196725

6720-
Thus, strictly following the storage key partitioning model described in
6726+
Thus, strictly following the storage partitioning model described in
67216727
this specification is important for user security.
67226728

67236729
If host names or database names are used to construct paths for
67246730
persistence to a file system they must be appropriately escaped to
6725-
prevent an adversary from accessing information from other [=/storage keys=]
6731+
prevent an adversary from accessing information from other [=/storage buckets=]
67266732
using relative paths such as "`../`".
67276733

67286734
## Persistence risks ## {#persistence-risks}
@@ -6805,6 +6811,7 @@ For the revision history of the second edition, see [that document's Revision Hi
68056811
* Specified [[#transaction-scheduling]] more precisely and disallow starting read/write transactions while read-only transactions with overlapping scope are running. ([Issue #253](https://github.com/w3c/IndexedDB/issues/253))
68066812
* Added <a href="#accessibility">Accessibility considerations</a> section. ([Issue #327](https://github.com/w3c/IndexedDB/issues/327))
68076813
* Used [[infra]]'s list sorting definition. ([Issue #346](https://github.com/w3c/IndexedDB/issues/346))
6814+
* Defined storage partitioning in terms of [[Storage]] primitives.
68086815

68096816
<!-- ============================================================ -->
68106817
# Acknowledgements # {#acknowledgements}

0 commit comments

Comments
 (0)