Search code examples
firefoxfirefox-addonfirefox-addon-sdk

Access Add-on SDK module from the scratchpad


I'd like to test small snippets of my add-on code using the scratchpad. In this case, I'm trying to access the notifications module like so:

const { notify } = require("sdk/notifications");
notify({
  //My notification's options
}); 

As expected, I get the error Exception: require is not defined. As the Add-on SDK is packaged with Firefox, I'm wondering if there's a way to access the modules directly from the scratchpad. Thanks.


Edit: After some Googling, I found scratch-kit (github), an add-on that does exactly what I'm trying to do. But it is unfortunately broken, so I've filed a bug in hopes that this functionality will be added to the devtools.


Solution

  • At the moment there isn't a way to do this. A few things could happen to make this possible which people can watch/contribute:

    1. scratch-kit is updated
    2. native jetpack is completed and is integrated with itchpad (which should replace scratch kit). I made an example which I blogged about but it's not ready for release yet.