Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IDBFactory/databases() #240

Merged
merged 2 commits into from
Oct 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2173,8 +2173,15 @@ interface IDBFactory {
optional [EnforceRange] unsigned long long version);
[NewObject] IDBOpenDBRequest deleteDatabase(DOMString name);

Promise<sequence<IDBDatabaseInfo>> databases();

short cmp(any first, any second);
};

dictionary IDBDatabaseInfo {
DOMString name;
unsigned long long version;
};
</xmp>


Expand Down Expand Up @@ -2213,6 +2220,18 @@ interface IDBFactory {
is successful |request|'s {{IDBRequest/result}}
will be null.
</dd>
<dt><var>result</var> = await indexedDB . {{IDBFactory/databases()|databases}}()</dt>
<dd>
<p>
Returns a promise which resolves to a list of objects giving a snapshot
of the names and versions of databases within the origin.

This API is intended for web applications to introspect the use of databases,
for example to clean up from earlier versions of a site's code. Note that
the result is a snapshot; there are no guarantees about the sequencing of the
collection of the data or the delivery of the response with respect to requests
to create, upgrade, or delete databases by this context or others.
</dd>
</dl>
</div>

Expand Down Expand Up @@ -2344,6 +2363,42 @@ when invoked, must run these steps:

</div>

<div class=algorithm>

The <dfn method for=IDBFactory>databases()</dfn> method,
when invoked, must run these steps:

1. Let |origin| be the [=/origin=] of the global scope used
to access this {{IDBFactory}}.

1. If |origin| is an [=opaque origin=],
then return a new promise rejected with a "{{NotSupportedError}}" {{DOMException}}.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other IDBFactory methods (open and deleteDatabase) throw a SecurityError DOMException upon an opaque origin. Is this deviation here deliberate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I see no indication, unlike the other IDBFactory methods, of what should happen if there are any errors in retrieving the info... If this would occur as a rejected Promise, does the error format need to be documented?

1. Let |p| be a new promise.

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

1. Let |databases| be a new [=/list=].

1. For each [=database=] |db| in |origin|:

1. Let |info| be a new {{IDBDatabaseInfo}} dictionary.
1. Set |info|'s {{IDBDatabaseInfo/name}} dictionary member to |db|'s [=database/name=].
1. Set |info|'s {{IDBDatabaseInfo/version}} dictionary member to |db|'s [=database/version=].
1. [=list/Append=] |info| to |databases|.

1. Resolve |p| with |databases|.

1. Return |p|.

</div>

<aside class=advisement>
&#x1F6A7;
The {{IDBFactory/databases()}} method is new in this edition.
&#x1F6A7;
</aside>

<div class=note>
<dl class=domintro>
<dt><var>result</var> = indexedDB .
Expand Down Expand Up @@ -6978,6 +7033,7 @@ For the revision history of the second edition, see [that document's Revision Hi

* The [=cleanup Indexed Database transactions=] algorithm now returns a value for integration with other specs. ([PR #232](https://github.com/w3c/IndexedDB/pull/232))
* Updated [partial interface definition](#global-scope) since {{WindowOrWorkerGlobalScope}} is now a `mixin` ([PR #238](https://github.com/w3c/IndexedDB/pull/238)).
* Added {{IDBFactory/databases()}} method. ([Issue #31](https://github.com/w3c/IndexedDB/issues/31))

<!-- ============================================================ -->
# Acknowledgements # {#acknowledgements}
Expand Down