Only one problem, is that there's some irritating new permissions thing that prevents content scripts (or web pages) from accessing chrome manifest registered resources, neither content:// urls (even with contentaccessible=yes flag set) or resource:// urls. This naturally makes fixing up any legacy extension that loads framescripts a little tricky.
At least for the moment, though, loadFrameScript will work with moz-extension:// urls, so as long as the framescript can be placed in one of those, it can still be loaded. To do this, create a minimal embedded webextension to hold your framescript as a resource. Add <em:hasEmbeddedWebExtension>true</em:hasEmbeddedWebExtension> to your install.rdf, and create a "webextension" folder at the top level of your addon. In that, put a manifest.json:
Code: Select all
{
"manifest_version": 2,
"name": "Embedded Resources",
"version": "0.1",
"background": {
"scripts": ["embedded_resources.js"]
},
"web_accessible_resources": [
"content/*"
]
}
Next to manifest.json, place "embedded_resources.js", which simply contains the line
Code: Select all
browser.runtime.sendMessage(browser.extension.getURL("content/"));
Code: Select all
function startup(data, reason) {
const globalMessageManager = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
data.webExtension.startup().then(api =>
api.browser.runtime.onMessage.addListener(embeddedResourceUrl => {
globalMessageManager.loadFrameScript(embeddedResourceUrl + "framescript.js", true);
})
);
}
Anyway, just thought I'd throw this out there in case anyone else is trying to patch up legacy addons to work under 57.