Bug 1263324 - Part 1: Fixing the cache storage inspector to obey originAttributes and indexedDB storage inspector to use correct database file name with originAttributes. r?mratcliffe
--- a/devtools/server/actors/storage.js
+++ b/devtools/server/actors/storage.js
@@ -1214,18 +1214,22 @@ StorageActors.createActor({
observationTopics: ["dom-storage2-changed", "dom-private-storage2-changed"]
}, getObjectForLocalOrSessionStorage("sessionStorage"));
StorageActors.createActor({
typeName: "Cache"
}, {
getCachesForHost: Task.async(function* (host) {
let uri = Services.io.newURI(host);
+ let attrs = this.storageActor
+ .document
+ .nodePrincipal
+ .originAttributes;
let principal =
- Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
+ Services.scriptSecurityManager.createCodebasePrincipal(uri, attrs);
// The first argument tells if you want to get |content| cache or |chrome|
// cache.
// The |content| cache is the cache explicitely named by the web content
// (service worker or web page).
// The |chrome| cache is the cache implicitely cached by the platform,
// hosting the source file of the service worker.
let { CacheStorage } = this.storageActor.window;
@@ -1659,21 +1663,21 @@ StorageActors.createActor({
for (let host of this.hosts) {
yield this.populateStoresForHost(host);
}
}),
populateStoresForHost: Task.async(function* (host) {
let storeMap = new Map();
- let {names} = yield this.getDBNamesForHost(host);
let win = this.storageActor.getWindowFromHost(host);
if (win) {
let principal = win.document.nodePrincipal;
+ let {names} = yield this.getDBNamesForHost(host, principal);
for (let {name, storage} of names) {
let metadata = yield this.getDBMetaData(host, principal, name, storage);
metadata = indexedDBHelpers.patchMetadataMapsAndProtos(metadata);
storeMap.set(`${name} (${storage})`, metadata);
}
@@ -2020,18 +2024,18 @@ var indexedDBHelpers = {
}
return this.backToChild("clearDBStore", null);
}),
/**
* Fetches all the databases and their metadata for the given `host`.
*/
- getDBNamesForHost: Task.async(function* (host) {
- let sanitizedHost = this.getSanitizedHost(host);
+ getDBNamesForHost: Task.async(function* (host, principal) {
+ let sanitizedHost = this.getSanitizedHost(host) + principal.originSuffix;
let profileDir = OS.Constants.Path.profileDir;
let files = [];
let names = [];
let storagePath = OS.Path.join(profileDir, "storage");
// We expect sqlite DB paths to look something like this:
// - PathToProfileDir/storage/default/http+++www.example.com/
// idb/1556056096MeysDaabta.sqlite
@@ -2358,18 +2362,18 @@ var indexedDBHelpers = {
let [host, principal, name, storage] = args;
return indexedDBHelpers.getDBMetaData(host, principal, name, storage);
}
case "splitNameAndStorage": {
let [name] = args;
return indexedDBHelpers.splitNameAndStorage(name);
}
case "getDBNamesForHost": {
- let [host] = args;
- return indexedDBHelpers.getDBNamesForHost(host);
+ let [host, principal] = args;
+ return indexedDBHelpers.getDBNamesForHost(host, principal);
}
case "getValuesForHost": {
let [host, name, options, hostVsStores, principal] = args;
return indexedDBHelpers.getValuesForHost(host, name, options,
hostVsStores, principal);
}
case "removeDB": {
let [host, principal, dbName] = args;