FYI, using COW (chrome object wrapper) for abitrary code should be avoided.
It is acceptable as first iteration as it doesn't introduce security leak, but here is the suggested way to inject an API:
  http://mxr.mozilla.org/mozilla-central/source/dom/base/ConsoleAPI.js#150
(The important part is Cu.createObjectIn and Cu.makeObjectPropsNormal)