add try/catch around accesses of window.API

Firefox's cross-site scripting security throws a "permission denied" when trying to access properties of the parent window, when it belongs to a differnet domain than the child.
This code catches that error, and adds it to the debug trace but otherwise fails silently.