Access Add-on SDK module from the scratchpad

后端 未结 2 1083
刺人心
刺人心 2021-02-06 18:04

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 } =         


        
相关标签:
2条回答
  • 2021-02-06 18:14

    By now there is a relatively simple way to do this. The following code works fine if executed in privileged context (meaning switching Scratchpad's environment to "Browser"):

    let {require} = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
    let {notify} = require("sdk/notifications");
    

    This is supported starting with Firefox 36 but not really documented as of now - meaning that this might stop working in future.

    For reference: pull request #1679 added this functionality (not meant for external use it seems).

    0 讨论(0)
  • 2021-02-06 18:31

    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.
    0 讨论(0)
提交回复
热议问题