diff --git a/devtools/client/storage/test/browser_storage_indexeddb_duplicate_names.js b/devtools/client/storage/test/browser_storage_indexeddb_duplicate_names.js index 0ba9016c5cde..9da6fb7da929 100644 --- a/devtools/client/storage/test/browser_storage_indexeddb_duplicate_names.js +++ b/devtools/client/storage/test/browser_storage_indexeddb_duplicate_names.js @@ -24,10 +24,8 @@ add_task(async function() { [ "idb1 (default)", "idb1 (temporary)", - "idb1 (persistent)", "idb2 (default)", "idb2 (temporary)", - "idb2 (persistent)", ], ], ]); diff --git a/devtools/client/storage/test/storage-indexeddb-duplicate-names.html b/devtools/client/storage/test/storage-indexeddb-duplicate-names.html index f549d4cbc5d8..197b101b682b 100644 --- a/devtools/client/storage/test/storage-indexeddb-duplicate-names.html +++ b/devtools/client/storage/test/storage-indexeddb-duplicate-names.html @@ -11,10 +11,8 @@ function createIndexedDBs() { createIndexedDB("idb1", "temporary"); createIndexedDB("idb1", "default"); - createIndexedDB("idb1", "persistent"); createIndexedDB("idb2", "temporary"); createIndexedDB("idb2", "default"); - createIndexedDB("idb2", "persistent"); } function createIndexedDB(name, storage) { @@ -36,10 +34,8 @@ window.clear = async function () { await deleteDB("idb1", "temporary"); await deleteDB("idb1", "default"); - await deleteDB("idb1", "persistent"); await deleteDB("idb2", "temporary"); await deleteDB("idb2", "default"); - await deleteDB("idb2", "persistent"); dump(`removed indexedDB data from ${document.location}\n`); }; diff --git a/devtools/client/storage/test/storage-overflow-indexeddb.html b/devtools/client/storage/test/storage-overflow-indexeddb.html index 9805e153ca2e..bab63ad5fe8c 100644 --- a/devtools/client/storage/test/storage-overflow-indexeddb.html +++ b/devtools/client/storage/test/storage-overflow-indexeddb.html @@ -41,7 +41,6 @@ function deleteDB(dbName, storage) { window.clear = async function() { await deleteDB("database", "temporary"); await deleteDB("database", "default"); - await deleteDB("database", "persistent"); dump(`removed indexedDB data from ${document.location}\n`); }; diff --git a/devtools/server/actors/storage.js b/devtools/server/actors/storage.js index 34268692bf92..496390b1db6c 100644 --- a/devtools/server/actors/storage.js +++ b/devtools/server/actors/storage.js @@ -27,8 +27,6 @@ loader.lazyGetter( () => Cu.getGlobalForObject(ExtensionProcessScript).WebExtensionPolicy ); -const CHROME_ENABLED_PREF = "devtools.chrome.enabled"; -const REMOTE_ENABLED_PREF = "devtools.debugger.remote-enabled"; const EXTENSION_STORAGE_ENABLED_PREF = "devtools.storage.extensionStorage.enabled"; @@ -49,8 +47,6 @@ const COOKIE_SAMESITE = { UNSET: "Unset", }; -const SAFE_HOSTS_PREFIXES_REGEX = /^(about\+|https?\+|file\+|moz-extension\+)/; - // GUID to be used as a separator in compound keys. This must match the same // constant in devtools/client/storage/ui.js, // devtools/client/storage/test/head.js and @@ -156,8 +152,7 @@ StorageActors.defaults = function(typeName, observationTopics) { /** * Returns a list of currently known hosts for the target window. This list - * contains unique hosts from the window + all inner windows. If - * this._internalHosts is defined then these will also be added to the list. + * contains unique hosts from the window + all inner windows. */ get hosts() { const hosts = new Set(); @@ -168,11 +163,6 @@ StorageActors.defaults = function(typeName, observationTopics) { hosts.add(host); } } - if (this._internalHosts) { - for (const host of this._internalHosts) { - hosts.add(host); - } - } return hosts; }, @@ -2329,7 +2319,7 @@ ObjectStoreMetadata.prototype = { * @param {IDBDatabase} db * The particular indexed db. * @param {String} storage - * Storage type, either "temporary", "default" or "persistent". + * Storage type, either "temporary" or "default". */ function DatabaseMetadata(origin, db, storage) { this._origin = origin; @@ -2402,21 +2392,6 @@ StorageActors.createActor( this.storageActor = null; }, - /** - * Returns a list of currently known hosts for the target window. This list - * contains unique hosts from the window, all inner windows and all permanent - * indexedDB hosts defined inside the browser. - */ - async getHosts() { - // Add internal hosts to this._internalHosts, which will be picked up by - // the this.hosts getter. Because this.hosts is a property on the default - // storage actor and inherited by all storage actors we have to do it this - // way. - this._internalHosts = await this.getInternalHosts(); - - return this.hosts; - }, - /** * Remove an indexedDB database from given host with a given name. */ @@ -2538,7 +2513,7 @@ StorageActors.createActor( async preListStores() { this.hostVsStores = new Map(); - for (const host of await this.getHosts()) { + for (const host of this.hosts) { await this.populateStoresForHost(host); } }, @@ -2651,7 +2626,6 @@ StorageActors.createActor( this.removeDB = indexedDBHelpers.removeDB; this.removeDBRecord = indexedDBHelpers.removeDBRecord; this.splitNameAndStorage = indexedDBHelpers.splitNameAndStorage; - this.getInternalHosts = indexedDBHelpers.getInternalHosts; return; } @@ -2668,10 +2642,6 @@ StorageActors.createActor( null, "splitNameAndStorage" ); - this.getInternalHosts = callParentProcessAsync.bind( - null, - "getInternalHosts" - ); this.getDBNamesForHost = callParentProcessAsync.bind( null, "getDBNamesForHost" @@ -2803,34 +2773,6 @@ var indexedDBHelpers = { return { storage, name }; }, - /** - * Get all "internal" hosts. Internal hosts are database namespaces used by - * the browser. - */ - async getInternalHosts() { - // Return an empty array if the browser toolbox is not enabled. - if ( - !Services.prefs.getBoolPref(CHROME_ENABLED_PREF) || - !Services.prefs.getBoolPref(REMOTE_ENABLED_PREF) - ) { - return this.backToChild("getInternalHosts", []); - } - - const profileDir = OS.Constants.Path.profileDir; - const storagePath = OS.Path.join(profileDir, "storage", "permanent"); - const iterator = new OS.File.DirectoryIterator(storagePath); - const hosts = []; - - await iterator.forEach(entry => { - if (entry.isDir && !SAFE_HOSTS_PREFIXES_REGEX.test(entry.name)) { - hosts.push(entry.name); - } - }); - iterator.close(); - - return this.backToChild("getInternalHosts", hosts); - }, - /** * Opens an indexed db connection for the given `principal` and * database `name`. @@ -2958,14 +2900,11 @@ var indexedDBHelpers = { // We expect sqlite DB paths to look something like this: // - PathToProfileDir/storage/default/http+++www.example.com/ // idb/1556056096MeysDaabta.sqlite - // - PathToProfileDir/storage/permanent/http+++www.example.com/ - // idb/1556056096MeysDaabta.sqlite // - PathToProfileDir/storage/temporary/http+++www.example.com/ // idb/1556056096MeysDaabta.sqlite // The subdirectory inside the storage folder is determined by the storage // type: // - default: { storage: "default" } or not specified. - // - permanent: { storage: "persistent" }. // - temporary: { storage: "temporary" }. const sqliteFiles = await this.findSqlitePathsForHost( storagePath, @@ -2980,7 +2919,7 @@ var indexedDBHelpers = { files.push({ file: relative, - storage: storage === "permanent" ? "persistent" : storage, + storage, }); } @@ -3035,7 +2974,7 @@ var indexedDBHelpers = { }, /** - * Find all the storage types, such as "default", "permanent", or "temporary". + * Find all the storage types, such as "default" or "temporary". * These names have changed over time, so it seems simpler to look through all * types that currently exist in the profile. */ @@ -3043,7 +2982,11 @@ var indexedDBHelpers = { const iterator = new OS.File.DirectoryIterator(storagePath); const typePaths = []; await iterator.forEach(entry => { - if (entry.isDir) { + if ( + entry.isDir && + (OS.Path.basename(entry.path) === "default" || + OS.Path.basename(entry.path) === "temporary") + ) { typePaths.push(entry.path); } }); @@ -3168,7 +3111,7 @@ var indexedDBHelpers = { * @param {string} dbName * The name of the indexed db from the above host. * @param {String} storage - * Storage type, either "temporary", "default" or "persistent". + * Storage type, either "temporary" or "default". * @param {Object} requestOptions * An object in the following format: * { @@ -3292,9 +3235,6 @@ var indexedDBHelpers = { const [host, principal, name, storage] = args; return indexedDBHelpers.getDBMetaData(host, principal, name, storage); } - case "getInternalHosts": { - return indexedDBHelpers.getInternalHosts(); - } case "splitNameAndStorage": { const [name] = args; return indexedDBHelpers.splitNameAndStorage(name); diff --git a/devtools/server/tests/browser/browser_storage_browser_toolbox_indexeddb.js b/devtools/server/tests/browser/browser_storage_browser_toolbox_indexeddb.js index c6fe2eedadb8..3cf91d3f6ead 100644 --- a/devtools/server/tests/browser/browser_storage_browser_toolbox_indexeddb.js +++ b/devtools/server/tests/browser/browser_storage_browser_toolbox_indexeddb.js @@ -45,9 +45,9 @@ async function testInternalDBs(front) { const data = await front.listStores(); const hosts = data.indexedDB.hosts; - ok(hosts.chrome, `indexedDB hosts contains "chrome"`); - - const path = `["MyDatabase (persistent)","MyObjectStore"]`; - const foundDB = hosts.chrome.includes(path); - ok(foundDB, `Host "chrome" includes ${path}`); + // According to bug 1594810 "persistent" storage is deprecated and we plan + // to remove support completely in dom/indexedDB. To make this possible + // we need to skip "persistent" storage entries to prevent the toolbox + // from breaking when support is removed. + ok(!hosts.chrome, `indexedDB hosts doesn't contain "chrome"`); } diff --git a/devtools/server/tests/unit/test_extension_storage_actor.js b/devtools/server/tests/unit/test_extension_storage_actor.js index 5168c204e847..ee6369fe23ea 100644 --- a/devtools/server/tests/unit/test_extension_storage_actor.js +++ b/devtools/server/tests/unit/test_extension_storage_actor.js @@ -5,10 +5,6 @@ "use strict"; -const { FileUtils } = ChromeUtils.import( - "resource://gre/modules/FileUtils.jsm" -); - const { ExtensionTestUtils } = ChromeUtils.import( "resource://testing-common/ExtensionXPCShellUtils.jsm" ); @@ -204,30 +200,8 @@ async function shutdown(extension, target) { await extension.unload(); } -/** - * Mocks the missing 'storage/permanent' directory needed by the "indexedDB" - * storage actor's 'preListStores' method (called when 'listStores' is called). This - * directory exists in a full browser i.e. mochitest. - */ -function createMissingIndexedDBDirs() { - const dir = Services.dirsvc.get("ProfD", Ci.nsIFile).clone(); - dir.append("storage"); - if (!dir.exists()) { - dir.create(dir.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); - } - dir.append("permanent"); - if (!dir.exists()) { - dir.create(dir.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); - } - Assert.ok( - dir.exists(), - "Should have a 'storage/permanent' dir in the profile dir" - ); -} - add_task(async function setup() { await promiseStartupManager(); - createMissingIndexedDBDirs(); }); add_task(async function test_extension_store_exists() {