indexedDB API is typically used to store data in the user's browser from content JavaScript.  (See 使用 IndexedDB for an overview.)  However, the APIs can also be accessed from system-privileged JavaScript using the Components.utils.importGlobalProperties() 函数:

Components.utils.importGlobalProperties(["indexedDB"]);
// From here on, it's like using IndexedDB from content
var req = indexedDB.open("my-database");
// ...
			

If you are creating a sandbox, and want indexedDB to be available in it, use the wantGlobalProperties option in the Sandbox 构造函数:

var options = {
  "wantGlobalProperties": ["indexedDB"]
}
var principal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
var sandbox = Components.utils.Sandbox(principal, options);
// The sandbox will have access to indexedDB
var sandboxScript = 'var req = indexedDB.open("my-database");';
Components.utils.evalInSandbox(sandboxScript, sandbox);
			

Before Firefox 33, you would access indexedDB from chrome code using the initWindowless 方法在 nsIIndexedDatabaseManager service. This method was removed in Firefox 33.

元数据

  1. IndexedDB API
  2. 指南
    1. 基本概念
    2. 浏览器存储限制和驱逐准则
    3. 校验当由于截止日期
    4. 使用 IndexedDB
  3. 接口
    1. IDBCursor
    2. IDBCursorSync
    3. IDBCursorWithValue
    4. IDBDatabase
    5. IDBDatabaseException
    6. IDBDatabaseSync
    7. IDBEnvironment
    8. IDBEnvironmentSync
    9. IDBFactory
    10. IDBFactorySync
    11. IDBIndex
    12. IDBIndexSync
    13. IDBKeyRange
    14. IDBObjectStore
    15. IDBObjectStoreSync
    16. IDBOpenDBRequest
    17. IDBRequest
    18. IDBTransaction
    19. IDBTransactionSync
    20. IDBVersionChangeEvent
    21. IDBVersionChangeRequest