1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * http://www.whatwg.org/html/#the-storage-interface
9 * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
10 * Opera Software ASA. You are granted a license to use, reproduce
11 * and create derivative works of this document.
16 [Throws, NeedsSubjectPrincipal]
17 readonly attribute unsigned long length;
19 [Throws, NeedsSubjectPrincipal]
20 DOMString? key(unsigned long index);
22 [Throws, NeedsSubjectPrincipal]
23 getter DOMString? getItem(DOMString key);
25 [Throws, NeedsSubjectPrincipal]
26 setter undefined setItem(DOMString key, DOMString value);
28 [Throws, NeedsSubjectPrincipal]
29 deleter undefined removeItem(DOMString key);
31 [Throws, NeedsSubjectPrincipal]
36 * Testing methods that exist only for the benefit of automated glass-box
37 * testing. Will never be exposed to content at large and unlikely to be useful
38 * in a WebDriver context.
40 partial interface Storage {
42 * Does a security-check and ensures the underlying database has been opened
43 * without actually calling any database methods. (Read-only methods will
44 * have a similar effect but also impact the state of the snapshot.)
46 [Throws, NeedsSubjectPrincipal, Pref="dom.storage.testing"]
50 * Automatically ends any explicit snapshot and drops the reference to the
51 * underlying database, but does not otherwise perturb the database.
53 [Throws, NeedsSubjectPrincipal, Pref="dom.storage.testing"]
57 * Ensures the database has been opened and initiates an explicit snapshot.
58 * Snapshots are normally automatically ended and checkpointed back to the
59 * parent, but explicitly opened snapshots must be explicitly ended via
60 * `endExplicitSnapshot` or `close`.
62 [Throws, NeedsSubjectPrincipal, Pref="dom.storage.testing"]
63 undefined beginExplicitSnapshot();
66 * Checkpoints the explicitly begun snapshot. This is only useful for testing
67 * of snapshot re-using when multiple checkpoints are involved. There's no
68 * need to call this before `endExplicitSnapshot` because it checkpoints the
69 * snapshot before it's ended.
71 [Throws, NeedsSubjectPrincipal, Pref="dom.storage.testing"]
72 undefined checkpointExplicitSnapshot();
75 * Ends the explicitly begun snapshot and retains the underlying database.
76 * Compare with `close` which also drops the reference to the database.
78 [Throws, NeedsSubjectPrincipal, Pref="dom.storage.testing"]
79 undefined endExplicitSnapshot();
82 * Returns true if the underlying database has been opened, the database is
83 * not being closed and it has a snapshot (initialized implicitly or
86 [Throws, NeedsSubjectPrincipal, Pref="dom.storage.testing"]
87 readonly attribute boolean hasSnapshot;
90 * Returns snapshot usage.
92 * @throws NS_ERROR_NOT_AVAILABLE if the underlying database hasn't been
93 * opened or the database is being closed or it doesn't have a
96 [Throws, NeedsSubjectPrincipal, Pref="dom.storage.testing"]
97 readonly attribute long long snapshotUsage;