1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * This indexedDB helper is a simplified version of sdk/indexed-db. It creates a DB with
9 * a principal dedicated to DevTools.
12 const PSEUDOURI = "indexeddb://fx-devtools";
13 const principaluri = Services.io.newURI(PSEUDOURI);
14 const principal = Services.scriptSecurityManager.createContentPrincipal(
19 // indexedDB is only exposed to document globals.
20 // We are retrieving an instance from a Sandbox, which has to be loaded
21 // from the system principal in order to avoid having wrappers around
22 // all indexed DB objects.
23 const systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
24 const sandbox = Cu.Sandbox(systemPrincipal, {
25 wantGlobalProperties: ["indexedDB"],
27 const { indexedDB } = sandbox;
29 module.exports = Object.freeze({
32 if (typeof version === "number") {
33 options.version = version;
35 return indexedDB.openForPrincipal(principal, name, options);
38 deleteDatabase(name) {
39 return indexedDB.deleteForPrincipal(principal, name);
42 cmp: indexedDB.cmp.bind(indexedDB),