Calling addon functionality from a unit test
I've made a firefox addon using the the addon-sdk and I'm trying to write unit tests for it now.
How can I access the addon functionality from the test? From what i see, they are separated, and I cannot simply access the addon f开发者_如何学运维unctions and variables of my addon.
You simply import the modules of your add-on. For example, if you have a module lib/foo.js
in your add-on you do:
var foo = require("foo");
Note that you will only be able to access the methods and variables that the module exports (essentially properties of its global exports
object).
The reading-data
example in the Add-on SDK uses that approach to load the add-on's main
module and to call the exported method main()
.
精彩评论