Expose addon object to content function as a parameter

I have a problem. I have a function defined on the page that takes an object as an argument lets say:

<script>
function dummyFunc(someobj)
{
  console.log(someobj.x);
  console.log(someobj.y);
}
</script>

I would like to call this function inside my addon. It works but the passed object is cannot be seen by dummyFunc!

var jso = window.content.document.defaultView.wrappedJSObject;

var o = { x: "apple", y: "pie" };
//  tried , __exposedProps__ : { x: "r", y: "r" } too!

jso.o = o;
jso.dummyFunc(o); // tried to pass jso.o too but it doesn't work. I can see the object in firebug but the function doesn't see it.

Suggestions?

You would use Cu.exportFunction:

https://developer.mozilla.org/en-US/docs/Components.utils.exportFunction

1 Like