Error thrown in xhr.onreadystatechange when javascript execution is suspended/resumed on iOS

Request Type: bug

How to reproduce: On iOS, javascript execution is suspended when user switches to another tab in browser, closes browser, performs back/forward using swipe gestions.
In our application, if http request is occurred when javascript execution is suspended/resumed, sometimes (apprx one time per dozen tries) the following error is thrown:

TypeError: 'null' is not an object (evaluating 'xhr.readyState')

  src/ng/httpBackend.js
  xhr.onreadystatechange = function() {
    if (xhr.readyState == 4) {  // Error is thrown in this line
Debugging showed that xhr.onreadystatechange was invoked several times with readyState=4. On the first invocation xhr was nullified in completeRequest function, and then, on subsequent invocations, error was thrown.

Unfortunately, I could not reproduce the problem in small example. But I found that jQuery and Zepto have appropriate guards. Please see, for example, madrobby/zepto#633

Component(s): $http

Impact: large

Complexity: small

This issue is related to: 

**Detailed Description:**

In certain cases Webkit will call the onreadystatechange method of a single XMLHttpRequest object multiple times indicating that it is ready (readyState == 4).

**Other Comments:**

The actual approach didn't work. I took the Zepto.js approach (see: https://github.com/madrobby/zepto/pull/633).

In addition to manual and unit tests, I run a angular website with 250k unique visitor a day, I tested this patch there using getsentry.com and got no erros.

See: #5426