jquery/jquery — pull request #537 by charliesome (2011-10-08 10:18:56+00:00)
Title: Changed $.isWindow to be slightly less crude

The current `$.isWindow` simply looks to see if the object has a `setInterval` property to decide if it is a window.

I've changed it to do a check that should be a little more robust (although still imperfect). What my implementation of `isWindow` does is:

* Checks `obj` and `obj.document` are objects
* Checks `obj.document`'s constructor is a function
* If so (Chrome), it tries to construct a new object with `obj.document`'s constructor. If it fails (you can't construct a new `HTMLDocument`), it decides `obj` is a window and returns true. Otherwise, it returns false.
* If not (Firefox, IE), it checks if `obj.document.constructor` is an `HTMLDocument` by calling `toString()` and checking if "HTMLDocument" is a substring.

I've run the test suite on Chrome 14 and Firefox 6 on Mac OS X, and Internet Explorer 8 on Windows XP. The test suite passes on all browsers.

I've also uncommented the 'fake window' test.