Can you please attach a testcase add-on?
That add-on seems to work as expected for me. In any case, I'd suggest converting the function to a string before passing it to createTextNode. And if you're using functions to inject code into pages like this, it would probably be best to always do something like `"(" + func + ")()"` rather than just injecting the bare function as a top-level function statement.
when "running" the code in the console it seems to work fine (without converting the function) should it be different ? about the self execution - it was just an example :)