Bläddra i källkod
Fixed some bugs in LoadFile
Two bugs fixed:
**HTTP errors being considered as a successful response**
Success was conditional on HTTP code 200 OR `ValidateXHRData()` returning true. When dataType is 1 (text) ValidateXHRData returns true if the response is a non-empty string. Often the response text will be set to some HTTP status error message (like "404 Not found") when the response fails, causing ValidateXHRData to return true and LoadFile to execute the callback.
I've removed the ValidateXHRData check from LoadFile because more generally we shouldn't want LoadFile to validate the data at all, just load it, then the user of LoadFile can validate anything returned based on their own criteria (e,g. whether or not it's a valid TGA)
I've also allowed it to accept all HTTP success codes (2XX)
**Callback being called twice in rare cases**
onreadystatechanged may be called multiple times with the value 4 (XMLHttpRequest.DONE), https://bugs.chromium.org/p/chromium/issues/detail?id=162837 nullifying it after it occurs once prevents this