Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Extension-side code
let AnObj = {
field: "hello",
thisIsATest: function() {
let str = this.field + " world!";
return str;
},
};
let thisIsATestBound = AnObj.thisIsATest.bind(AnObj);
Components.utils.exportFunction(AnObj.thisIsATest, window,
{defineAs: "thisIsATest"});
Components.utils.exportFunction(thisIsATestBound, window,
{defineAs: "thisIsATestBound"});
// User-side code
console.log(thisIsATest()); // "undefined world!"
console.log(thisIsATestBound()); // "hello world!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.