Just some snippets for now. I'll clean this up into an article later (maybe).
https://bugzilla.mozilla.org/show_bug.cgi?id=1019194
- create a new profile for addon development
- use the Developer Extension to set a bunch of prefs
- go into the profile, then into the profile's "extensions" directory.
- create a file with a name that matches the "em:id" in your install.rdf (the thing that looks like
myaddon@some-company
). I think you have something analogous in package.json, but this shit is all so confusing, still. - inside the file, put the full absolute path to the addon, with a trailing slash.
chrome.manifest maps "chrome" URLs to files inside your addon.
- suppose the path to a file is "myaddon/chrome/libs/foo.js".
- you specify a line in chrome manifest like this: "content myaddon chrome/libs/"
- then the chrome URL will be: "chrome://myaddon/content/foo.js".
- If you forget the 'content' slug, all is lost.
- good news: you can test this by opening firefox with your (possibly broken) addon installed, then type the chrome URL into the address bar. if it resolves to a file, you're all set. if not, start debugging.
- not much to say about this, except that it's mentioned somewhere on MDN and it sucks.
I accidentally put the XBL <content>
section inside the <implementation>
section.
XBL, like all truly great programming environments, fails silently if anything is wrong. Is it a JS error? XML syntax problem? Did the CSS selector fail to attach the XBL binding to the XUL page? Who the fuck knows?!
I was never able to figure out how to construct a chrome URL using tools exposed by the addon sdk.
I wound up losing a week reading about it, then dropped down to "restartless non-overlay non-sdk addon" approach.
YMMV. Using XBL makes everything so weirdly difficult.
How to define a global in addon code (not content scripts), or access that global from the addon debugger:
var {Cc, Ci} = require('chrome');
var winMediator = Cc['@mozilla.org/appshell/window-mediator;1']
.getService(Ci.nsIWindowMediator);
var window = winMediator.getMostRecentWindow('navigator:browser');
// now you can set globals on window:
window.LOL = {};