Bug 1572298 - Port Bug 1280216 "Remove nsIAboutModule::GetIndexedDBOriginPostfix()". r=IanN a=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Sun, 11 Aug 2019 14:17:50 +0200
changeset 32263 70f19359835b5bb33f830cd140d0e5159a120701
parent 32262 3819fbc7686bbde419f6b5ace2bc9c2908afae61
child 32264 9808d6a96ac92330212e2c8a9e441e6550dae2f3
push id209
push userfrgrahl@gmx.net
push dateSun, 11 Aug 2019 12:21:39 +0000
treeherdercomm-esr60@7a01e33fff91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, IanN
bugs1572298, 1280216
Bug 1572298 - Port Bug 1280216 "Remove nsIAboutModule::GetIndexedDBOriginPostfix()". r=IanN a=IanN Also warn about missing loadInfo parameter for about urls and provide a principal for non chrome priviledged content.
suite/components/nsAbout.js
--- a/suite/components/nsAbout.js
+++ b/suite/components/nsAbout.js
@@ -42,32 +42,35 @@ About.prototype = {
     return aURI.pathQueryRef.replace(/-|\W.*$/g, "").toLowerCase();
   },
 
   getURIFlags: function(aURI) {
     return this[this.getModule(aURI) + "Flags"];
   },
 
   newChannel: function(aURI, aLoadInfo) {
-    var module = this.getModule(aURI);
-    var newURI = Services.io.newURI(this[module + "URI"]);
-    var channel = aLoadInfo ?
+    let module = this.getModule(aURI);
+    let newURI = Services.io.newURI(this[module + "URI"]);
+
+    // We want a happy family which is always providing a loadInfo object.
+    if (!aLoadInfo) {
+      // Write out an error so that we have a stack and can fix the caller.
+      Cu.reportError('aLoadInfo was not provided in nsAbout.newChannel!');
+    }
+
+    let channel = aLoadInfo ?
                   Services.io.newChannelFromURIWithLoadInfo(newURI, aLoadInfo) :
                   Services.io.newChannelFromURI2(newURI, null,
                                                  Services.scriptSecurityManager.getSystemPrincipal(),
                                                  null,
                                                  Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                                                  Ci.nsIContentPolicy.TYPE_OTHER);
+
     channel.originalURI = aURI;
-    if (this[module + "Flags"] & UNTRUSTED)
-      channel.owner = null;
+    if (this[module + "Flags"] & UNTRUSTED) {
+      let principal = Services.scriptSecurityManager.createCodebasePrincipal(aURI, {});
+      channel.owner = principal;
+    }
     return channel;
   },
-
-  getIndexedDBOriginPostfix: function(aURI) {
-    if (this.getURIFlags(aURI) & INDEXEDDB) {
-      return this[this.getModule(aURI) + "Postfix"] || null;
-    }
-    throw Cr.NS_ERROR_ILLEGAL_VALUE;
-  }
 };
 
 var NSGetFactory = XPCOMUtils.generateNSGetFactory([About]);