Bug 1287007 - Set the principal in ChildAPIManager
The `browser.downloads.download` API takes a "url" parameter. The schema
file at downloads.json defines the type to be "url". This means that the
parameter is checked with `context.checkLoadURL(url)` in Schemas.jsm.
This method uses the principal of the object that was passed to
`Schemas.inject`.
Currently, this works just fine because the `schemaWrapper` in
Extension.jsm returns the context's principal.
But when we move to using the ChildAPIManager, the principal is not
defined and Schemas.jsm will fall back to a Null principal.
As a result, the test_ext_downloads_download.js fails because the
blob:-URL with the extension origin cannot be loaded by a null
principal. To fix this, the context's principal must be set.
MozReview-Commit-ID: FmpqYfPemyY
--- a/toolkit/components/extensions/ExtensionUtils.jsm
+++ b/toolkit/components/extensions/ExtensionUtils.jsm
@@ -1859,16 +1859,20 @@ class ChildAPIManager {
close() {
this.messageManager.sendAsyncMessage("API:CloseProxyContext", {childId: this.id});
}
get cloneScope() {
return this.context.cloneScope;
}
+ get principal() {
+ return this.context.principal;
+ }
+
shouldInject(namespace, name, allowedContexts) {
// Do not generate content script APIs, unless explicitly allowed.
return this.context.envType !== "content_child" || allowedContexts.includes("content");
}
getImplementation(namespace, name) {
let pathObj = this.localApis;
if (pathObj) {