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 Services = require("Services");
14 const PSEUDOURI = "indexeddb://fx-devtools";
15 const principaluri = Services.io.newURI(PSEUDOURI);
16 const principal = Services.scriptSecurityManager.createContentPrincipal(
22 * Create the DevTools dedicated DB, by relying on the real indexedDB object passed as a
25 * @param {IDBFactory} indexedDB
26 * Real indexedDB object.
27 * @return {Object} Wrapper object that implements IDBFactory methods, but for a devtools
30 exports.createDevToolsIndexedDB = function(indexedDB) {
31 return Object.freeze({
33 * Only the standard version of indexedDB.open is supported.
37 if (typeof version === "number") {
38 options.version = version;
40 return indexedDB.openForPrincipal(principal, name, options);
43 * Only the standard version of indexedDB.deleteDatabase is supported.
45 deleteDatabase(name) {
46 return indexedDB.deleteForPrincipal(principal, name);
48 cmp: indexedDB.cmp.bind(indexedDB),