if you try to access document.styleSheets.item() with some string as a parameter it returns the first style sheet. It should be throwing an exception
hmm.... document.styleSheets.item(0) and document.styleSheet.item("heh") should be equivalent -- the "heh" is cast to a number by the JS engine and its numeric value is 0. Not sure what Infinity and NaN are doing...
So the question then is what NaN and Infinity get coerced to when passed through XPConnect as an unsigned int....
XPConnect uses JS_ValueToECMAUint32. So what ever that API does for that conversion, so will XPConnect, including failing if the function returns false. The key is probably here: http://lxr.mozilla.org/seamonkey/source/js/src/jsnum.c#703
Mass-reassigning bugs to firstname.lastname@example.org
Web IDL says that "foo", NaN and Infinity all get converted to 0 when the type is "unsigned long" as it is for document.styleSheets.item().