I want to use my own console for my extension, where I would be printing out various debug info. I thought I would do that by doing
window.open("chrome://myextension/content/console.xul"..
and then printing into textboxes of that window. Do you already see something wrong here? =)
Now I have a small problem, window.open returns immediately and if I then go ahead and immediately use myconsole.log("boo") function, then the content in that newly opened window is not loaded yet and I will get errors. This means that I have to wait for the console to finish loading before I can print to it. What would be the right way of doing it? I could use nsITimer or thread.sleep inside of the log method to keep checking if it's loaded already, but I don't like this. I also don't know how I could correctly use window.onload event, because the only way I see is smth like window.onload = function() { all of my extension code.. } which I don't like either.
I want it to be used anytime anywhere somehow like this
console = Cc["@myconsole;1"].getService().wrappedJSObject;
console.log("foo");
Any advice? Thanks for the patience =)