Processing.js fixed when running inside a firefox extension

I've tried to run processing.js inside a firefox extension that we were doing.
We found a few erros and we fixed it.
They happened because of the implementation of XULDocument that replaces the actual document.