Ticket #3528 (closed defect: fixed)
If IE7's user-agent string gets too long, addOnLoad fails.
| Reported by: | guest | Owned by: | anonymous |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.9beta |
| Component: | General | Version: | 0.4.2 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
This is a very odd one, but we encountered it in testing our site. If you add extra identifiers to IE7's user agent string that add up to more than 260 or so characters, IE7 has a bug that makes it report that it is IE6. This in turn makes functions passed into addOnLoad not get called.
To repro:
1) Go into your registry using Regedit.exe.
2) Navigate to HKLMSoftwareMicrosoftWindowsCurrentVersionInternet Settings5.0User AgentPost? Platform
3) Create a *new* string key with a very long *name* (the value can be blank). I've used "long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key long key" as my key.
4) Close all instances of IE.
5) Fire up IE and point it at a page that uses dojo.addOnLoad. It will not call any of the onLoad functions you send to it.
IE7 adds all of the names of keys in Post Platform to the end of the User Agent string. However, when those strings add up to more than 260 characters or so, the call to navigator.userAgent has a bug and always returns "Mozilla/4.0 (compatible; MSIE 6.0)". Since it doesn't say "Windows" in the UA string, dojo sets dojo.render.os.win to false.
Now, when it comes to adding the onload event, dojo has the following test for the IE branch:
if(dojo.render.html.ie && dojo.render.os.win){
document.attachEvent("onreadystatechange", function(e){
if(document.readyState == "complete"){
dj_load_init();
}
});
}
Since, dojo.render.os.win is false, it doesn't hit this branch, and dj_load_init is never called.
I know this is a bit of a far-fetched corner case, but if someone has a bunch of .NET CLRs, spyware, or toolbars installed, their User Agent string can get quite long. And when it happens, it's pretty difficult to debug.
Interestingly, the UA string sent to servers does not have this bug; it's only in the UA string from navigator.userAgent.