(runtime)
| 5721 | } |
| 5722 | |
| 5723 | function exec(runtime) { |
| 5724 | _xhr.bind('LoadStart', function(e) { |
| 5725 | _p('readyState', XMLHttpRequest.LOADING); |
| 5726 | self.dispatchEvent('readystatechange'); |
| 5727 | |
| 5728 | self.dispatchEvent(e); |
| 5729 | |
| 5730 | if (_upload_events_flag) { |
| 5731 | self.upload.dispatchEvent(e); |
| 5732 | } |
| 5733 | }); |
| 5734 | |
| 5735 | _xhr.bind('Progress', function(e) { |
| 5736 | if (_p('readyState') !== XMLHttpRequest.LOADING) { |
| 5737 | _p('readyState', XMLHttpRequest.LOADING); // LoadStart unreliable (in Flash for example) |
| 5738 | self.dispatchEvent('readystatechange'); |
| 5739 | } |
| 5740 | self.dispatchEvent(e); |
| 5741 | }); |
| 5742 | |
| 5743 | _xhr.bind('UploadProgress', function(e) { |
| 5744 | if (_upload_events_flag) { |
| 5745 | self.upload.dispatchEvent({ |
| 5746 | type: 'progress', |
| 5747 | lengthComputable: false, |
| 5748 | total: e.total, |
| 5749 | loaded: e.loaded |
| 5750 | }); |
| 5751 | } |
| 5752 | }); |
| 5753 | |
| 5754 | _xhr.bind('Load', function(e) { |
| 5755 | _p('readyState', XMLHttpRequest.DONE); |
| 5756 | _p('status', Number(runtime.exec.call(_xhr, 'XMLHttpRequest', 'getStatus') || 0)); |
| 5757 | _p('statusText', httpCode[_p('status')] || ""); |
| 5758 | |
| 5759 | _p('response', runtime.exec.call(_xhr, 'XMLHttpRequest', 'getResponse', _p('responseType'))); |
| 5760 | |
| 5761 | if (!!~Basic.inArray(_p('responseType'), ['text', ''])) { |
| 5762 | _p('responseText', _p('response')); |
| 5763 | } else if (_p('responseType') === 'document') { |
| 5764 | _p('responseXML', _p('response')); |
| 5765 | } |
| 5766 | |
| 5767 | _responseHeaders = runtime.exec.call(_xhr, 'XMLHttpRequest', 'getAllResponseHeaders'); |
| 5768 | |
| 5769 | self.dispatchEvent('readystatechange'); |
| 5770 | |
| 5771 | if (_p('status') > 0) { // status 0 usually means that server is unreachable |
| 5772 | if (_upload_events_flag) { |
| 5773 | self.upload.dispatchEvent(e); |
| 5774 | } |
| 5775 | self.dispatchEvent(e); |
| 5776 | } else { |
| 5777 | _error_flag = true; |
| 5778 | self.dispatchEvent('error'); |
| 5779 | } |
| 5780 | loadEnd(); |
no test coverage detected