Make changes in the source file, not the generated one...
This commit is contained in:
parent
95b36b27ed
commit
3bcea3fab3
@ -107,6 +107,14 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extend(FakeXMLHttpRequest, {
|
||||||
|
UNSENT: 0,
|
||||||
|
OPENED: 1,
|
||||||
|
HEADERS_RECEIVED: 2,
|
||||||
|
LOADING: 3,
|
||||||
|
DONE: 4
|
||||||
|
});
|
||||||
|
|
||||||
var iePropertiesThatCannotBeCopied = ['responseBody', 'responseText', 'responseXML', 'status', 'statusText', 'responseTimeout', 'responseURL'];
|
var iePropertiesThatCannotBeCopied = ['responseBody', 'responseText', 'responseXML', 'status', 'statusText', 'responseTimeout', 'responseURL'];
|
||||||
extend(FakeXMLHttpRequest.prototype, new global.XMLHttpRequest(), iePropertiesThatCannotBeCopied);
|
extend(FakeXMLHttpRequest.prototype, new global.XMLHttpRequest(), iePropertiesThatCannotBeCopied);
|
||||||
extend(FakeXMLHttpRequest.prototype, {
|
extend(FakeXMLHttpRequest.prototype, {
|
||||||
@ -115,7 +123,7 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
|
|||||||
this.url = arguments[1];
|
this.url = arguments[1];
|
||||||
this.username = arguments[3];
|
this.username = arguments[3];
|
||||||
this.password = arguments[4];
|
this.password = arguments[4];
|
||||||
this.readyState = 1;
|
this.readyState = FakeXMLHttpRequest.OPENED;
|
||||||
this.requestHeaders = {};
|
this.requestHeaders = {};
|
||||||
this.eventBus.trigger('readystatechange');
|
this.eventBus.trigger('readystatechange');
|
||||||
},
|
},
|
||||||
@ -133,7 +141,7 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
abort: function() {
|
abort: function() {
|
||||||
this.readyState = 0;
|
this.readyState = FakeXMLHttpRequest.UNSENT;
|
||||||
this.status = 0;
|
this.status = 0;
|
||||||
this.statusText = "abort";
|
this.statusText = "abort";
|
||||||
this.eventBus.trigger('readystatechange');
|
this.eventBus.trigger('readystatechange');
|
||||||
@ -142,7 +150,7 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
|
|||||||
this.eventBus.trigger('loadend');
|
this.eventBus.trigger('loadend');
|
||||||
},
|
},
|
||||||
|
|
||||||
readyState: 0,
|
readyState: FakeXMLHttpRequest.UNSENT,
|
||||||
|
|
||||||
onloadstart: null,
|
onloadstart: null,
|
||||||
onprogress: null,
|
onprogress: null,
|
||||||
@ -226,7 +234,7 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
|
|||||||
case null:
|
case null:
|
||||||
case "":
|
case "":
|
||||||
case "text":
|
case "text":
|
||||||
return this.readyState >= 3 ? this.responseText : "";
|
return this.readyState >= FakeXMLHttpRequest.LOADING ? this.responseText : "";
|
||||||
case "json":
|
case "json":
|
||||||
return JSON.parse(this.responseText);
|
return JSON.parse(this.responseText);
|
||||||
case "arraybuffer":
|
case "arraybuffer":
|
||||||
@ -240,20 +248,20 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
|
|||||||
|
|
||||||
|
|
||||||
respondWith: function(response) {
|
respondWith: function(response) {
|
||||||
if (this.readyState === 4) {
|
if (this.readyState === FakeXMLHttpRequest.DONE) {
|
||||||
throw new Error("FakeXMLHttpRequest already completed");
|
throw new Error("FakeXMLHttpRequest already completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.status = response.status;
|
this.status = response.status;
|
||||||
this.statusText = response.statusText || "";
|
this.statusText = response.statusText || "";
|
||||||
this.responseHeaders = normalizeHeaders(response.responseHeaders, response.contentType);
|
this.responseHeaders = normalizeHeaders(response.responseHeaders, response.contentType);
|
||||||
this.readyState = 2;
|
this.readyState = FakeXMLHttpRequest.HEADERS_RECEIVED;
|
||||||
this.eventBus.trigger('readystatechange');
|
this.eventBus.trigger('readystatechange');
|
||||||
|
|
||||||
this.responseText = response.responseText || "";
|
this.responseText = response.responseText || "";
|
||||||
this.responseType = response.responseType || "";
|
this.responseType = response.responseType || "";
|
||||||
this.responseURL = response.responseURL || null;
|
this.responseURL = response.responseURL || null;
|
||||||
this.readyState = 4;
|
this.readyState = FakeXMLHttpRequest.DONE;
|
||||||
this.responseXML = getResponseXml(response.responseText, this.getResponseHeader('content-type') || '');
|
this.responseXML = getResponseXml(response.responseText, this.getResponseHeader('content-type') || '');
|
||||||
if (this.responseXML) {
|
if (this.responseXML) {
|
||||||
this.responseType = 'document';
|
this.responseType = 'document';
|
||||||
@ -272,10 +280,10 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
responseTimeout: function() {
|
responseTimeout: function() {
|
||||||
if (this.readyState === 4) {
|
if (this.readyState === FakeXMLHttpRequest.DONE) {
|
||||||
throw new Error("FakeXMLHttpRequest already completed");
|
throw new Error("FakeXMLHttpRequest already completed");
|
||||||
}
|
}
|
||||||
this.readyState = 4;
|
this.readyState = FakeXMLHttpRequest.DONE;
|
||||||
jasmine.clock().tick(30000);
|
jasmine.clock().tick(30000);
|
||||||
this.eventBus.trigger('readystatechange');
|
this.eventBus.trigger('readystatechange');
|
||||||
this.eventBus.trigger('progress');
|
this.eventBus.trigger('progress');
|
||||||
@ -284,10 +292,10 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
responseError: function() {
|
responseError: function() {
|
||||||
if (this.readyState === 4) {
|
if (this.readyState === FakeXMLHttpRequest.DONE) {
|
||||||
throw new Error("FakeXMLHttpRequest already completed");
|
throw new Error("FakeXMLHttpRequest already completed");
|
||||||
}
|
}
|
||||||
this.readyState = 4;
|
this.readyState = FakeXMLHttpRequest.DONE;
|
||||||
this.eventBus.trigger('readystatechange');
|
this.eventBus.trigger('readystatechange');
|
||||||
this.eventBus.trigger('progress');
|
this.eventBus.trigger('progress');
|
||||||
this.eventBus.trigger('error');
|
this.eventBus.trigger('error');
|
||||||
|
Loading…
Reference in New Issue
Block a user