fluidinfo/fluidinfo.js — pull request #72 by jkakar (2012-02-12 16:01:19+00:00)
Title: fail-404-slash-values-request-69

This branch introduces the following changes:

- I've added a test to ensure that a 404 results in the error handler
being called, but it exercises a code path with working logic.

It took awhile, but I discovered that the `FakeXHRHttpRequest` we use
in tests only ever exercises the second (old skool) branch in the
logic here (line 414 in the branch):

// A hack due to bugs in Android browsers
var isAndroid =
navigator.userAgent.toLowerCase().indexOf("android") >= 0;
if('onprogress' in xhr && !isAndroid) {
xhr.onerror = function() {
// handle problems nicely.
var result = createNiceResult(xhr);
options.onError(result);
};
xhr.onload = function() {
// process a good result.
handleResult();
};
} else {
xhr.onreadystatechange = function() {
// Old skool handling of XHR for older browsers.
if (xhr.readyState != 4) return;
handleResult();
};
}

The `handleResult` function is new in the branch, but in the logic it
changes the `xhr.onload` handler *always* calls `options.onSuccess`,
which is where the bug lies. I spent some time digging around `sinon`
to see if I could kick into looking like new skool request, but I
couldn't find a way.

Fixes #69.