Bug 1675375 Part 7: Update expectations in helper_hittest_clippath.html. r=botond
[gecko.git] / devtools / shared / indexed-db.js
blobaa895dce34e8d44f9055174968203281215efe99
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/. */
5 "use strict";
7 /**
8  * This indexedDB helper is a simplified version of sdk/indexed-db. It creates a DB with
9  * a principal dedicated to DevTools.
10  */
12 const Services = require("Services");
14 const PSEUDOURI = "indexeddb://fx-devtools";
15 const principaluri = Services.io.newURI(PSEUDOURI);
16 const principal = Services.scriptSecurityManager.createContentPrincipal(
17   principaluri,
18   {}
21 /**
22  * Create the DevTools dedicated DB, by relying on the real indexedDB object passed as a
23  * parameter here.
24  *
25  * @param {IDBFactory} indexedDB
26  *        Real indexedDB object.
27  * @return {Object} Wrapper object that implements IDBFactory methods, but for a devtools
28  *         specific principal.
29  */
30 exports.createDevToolsIndexedDB = function(indexedDB) {
31   return Object.freeze({
32     /**
33      * Only the standard version of indexedDB.open is supported.
34      */
35     open(name, version) {
36       const options = {};
37       if (typeof version === "number") {
38         options.version = version;
39       }
40       return indexedDB.openForPrincipal(principal, name, options);
41     },
42     /**
43      * Only the standard version of indexedDB.deleteDatabase is supported.
44      */
45     deleteDatabase(name) {
46       return indexedDB.deleteForPrincipal(principal, name);
47     },
48     cmp: indexedDB.cmp.bind(indexedDB),
49   });