I've have encountered a small annoyance that blows up to be a huge problem.
Problem 1: In Internet Explorer when you close a window (that you opened via window.open) the ownerDocument will disappear along with it.
The implication of this is that any call to the DOM, such as appendChild or createElement, will fail with a SCRIPT70: Permission Denied or SCRIPT1717: The interface is unknown.
I've looked at the behaviour of other browsers such as Chrome. In Chrome ownerDocument still references the #document but ownerDocument.defaultView will eventually be undefined. This makes sense to me. Calls to appendChild and createElement will pass. I think everything is fine so long as you don't try to reference the defaultView directly.
Problem 2: In Internet Explorer when you click on the close button of the spawned window it doesn't seem to respect the Event loop. I attached an unload event to the spawned window and it fires immediately instead of queuing it at the end of the Event loop. This does not make sense to me. It becomes quite impossible to deal with this rather trivial problem.
If we just had problem 1 there would be a -still painful but- straightforward solution: check if the ownerDocument exists and skip if it doesn't. As it is ownerDocument disappears in the middle of synchronous JavaScript code.
Expected behaviour: a DOM node should not disappear if you've referenced it - garbage collection sanity.
Expected behaviour 2: a DOM node should not disappear in synchronous code. (unless you delete it of course).
Known workaround: move all the code that interacts with the DOM into the window