On 12/14/12 6:49 AM, Jungkee Song wrote:
FWIW, document.open() does not create a new Window object
Yes, it does. See
http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#dom-document-open
processing steps step 14. WebKit gets this wrong, but other UAs do it
right.
console.log(defaultDoc.defaultView.name); // "InitWindow"
That's logging the navigation context name.
console.log(document.defaultView.name); // "InitWindow"
That's still logging the navigation context name.
In particular, in the case above this:
alert(XMLHttpRequest == window.XMLHttpRequest);
alerts false per spec as far as I can tell, and the old Window is no
longer associated with the document at this point.
In the above example, as both of the two global objects refer to the same
object, it results in "true".
Did you actually test this in a non-WebKit UA? The alert above alerts
false in Gecko, as the spec requires it to.
But note that you can get the same effect by just navigating the a
browsing context, then calling a function that was defined in the
no-longer-active document, without worrying about browsers that have
buggy open() implementations.
-Boris