mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1361333 - move sdk/util/indexed-db to devtools;r=ochameau
MozReview-Commit-ID: Lt4V6kmQACq --HG-- extra : rebase_source : 80bdaa517bdfa6863f963c7ed8a5275ba7415c18
This commit is contained in:
parent
40b5eb5426
commit
dc05133f8b
@ -20,8 +20,6 @@ this.EXPORTED_SYMBOLS = ["DevToolsLoader", "devtools", "BuiltinProvider",
|
||||
* Providers are different strategies for loading the devtools.
|
||||
*/
|
||||
|
||||
var sharedGlobalBlocklist = ["sdk/indexed-db"];
|
||||
|
||||
/**
|
||||
* Used when the tools should be loaded from the Firefox package itself.
|
||||
* This is the default case.
|
||||
@ -73,7 +71,7 @@ BuiltinProvider.prototype = {
|
||||
paths,
|
||||
invisibleToDebugger: this.invisibleToDebugger,
|
||||
sharedGlobal: true,
|
||||
sharedGlobalBlocklist,
|
||||
sharedGlobalBlocklist: [],
|
||||
sandboxName: "DevTools (Module loader)",
|
||||
noSandboxAddonId: true,
|
||||
requireHook: (id, require) => {
|
||||
|
@ -302,5 +302,7 @@ lazyGlobal("WebSocket", () => {
|
||||
return Services.appShell.hiddenDOMWindow.WebSocket;
|
||||
});
|
||||
lazyGlobal("indexedDB", () => {
|
||||
return require("sdk/indexed-db").indexedDB;
|
||||
let { indexedDB } = Cu.Sandbox(CC("@mozilla.org/systemprincipal;1", "nsIPrincipal")(),
|
||||
{wantGlobalProperties: ["indexedDB"]});
|
||||
return require("devtools/shared/indexed-db").createDevToolsIndexedDB(indexedDB);
|
||||
});
|
||||
|
52
devtools/shared/indexed-db.js
Normal file
52
devtools/shared/indexed-db.js
Normal file
@ -0,0 +1,52 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* This indexedDB helper is a simplified version of sdk/indexed-db. It creates a DB with
|
||||
* a principal dedicated to DevTools.
|
||||
*/
|
||||
|
||||
const { Cc, Ci } = require("chrome");
|
||||
|
||||
const PSEUDOURI = "indexeddb://fx-devtools";
|
||||
const principaluri = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService).newURI(PSEUDOURI);
|
||||
|
||||
const ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Ci.nsIScriptSecurityManager);
|
||||
|
||||
const principal = ssm.createCodebasePrincipal(principaluri, {});
|
||||
|
||||
/**
|
||||
* Create the DevTools dedicated DB, by relying on the real indexedDB object passed as a
|
||||
* parameter here.
|
||||
*
|
||||
* @param {IDBFactory} indexedDB
|
||||
* Real indexedDB object.
|
||||
* @return {Object} Wrapper object that implements IDBFactory methods, but for a devtools
|
||||
* specific principal.
|
||||
*/
|
||||
exports.createDevToolsIndexedDB = function (indexedDB) {
|
||||
return Object.freeze({
|
||||
/**
|
||||
* Only the standard version of indexedDB.open is supported.
|
||||
*/
|
||||
open(name, version) {
|
||||
let options = { storage: "persistent" };
|
||||
if (typeof version === "number") {
|
||||
options.version = version;
|
||||
}
|
||||
return indexedDB.openForPrincipal(principal, name, options);
|
||||
},
|
||||
/**
|
||||
* Only the standard version of indexedDB.deleteDatabase is supported.
|
||||
*/
|
||||
deleteDatabase(name) {
|
||||
return indexedDB.deleteForPrincipal(principal, name, { storage: "persistent" });
|
||||
},
|
||||
cmp: indexedDB.cmp.bind(indexedDB),
|
||||
});
|
||||
};
|
@ -57,6 +57,7 @@ DevToolsModules(
|
||||
'flags.js',
|
||||
'generate-uuid.js',
|
||||
'indentation.js',
|
||||
'indexed-db.js',
|
||||
'l10n.js',
|
||||
'loader-plugin-raw.jsm',
|
||||
'Loader.jsm',
|
||||
|
Loading…
Reference in New Issue
Block a user