It seems that Wladimir's answer is useful for most of such cases. But there is one more case.
I've found tris page trying to solve the problem with this error under Firefox 16. Strange, but I've never saw this error under Firefox 15.
I've got this error in content script on some pages. The script was injected at the start:
contentScriptWhen : "start",
It looks like in some cases window object was not initialized correctly. So, I've just changed script loading from start to end. It was possible in my case. The problem has gone...
I don't know why it appears, but know solution and hope that it will be useful for someone.