It's a lot simpler now actually see following link for example:
https://github.com/mozilla/addon-sdk/blob/master/test/addons/addon-page/main.js#L31-L45