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 draft
authorTim Huang <tihuang@mozilla.com>
Tue, 24 Jan 2017 17:00:01 +0800
changeset 479198 6965dc8731fb2c4b5024c77cd204e798142efad8
parent 479141 20a8536b0bfac74389d3a57bd8dd957d98779ce1
child 479199 ba4149fe88edc9ac59b9ad216fc03923f96a8541
push id44182
push userbmo:tihuang@mozilla.com
push dateMon, 06 Feb 2017 08:41:20 +0000
reviewersmratcliffe
bugs1263324
milestone54.0a1
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
devtools/server/actors/storage.js
--- 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;