diff --git a/lib/fake-xhr/index.js b/lib/fake-xhr/index.js index 9488f59..8be74c9 100644 --- a/lib/fake-xhr/index.js +++ b/lib/fake-xhr/index.js @@ -804,6 +804,8 @@ function fakeXMLHttpRequestFor(globalScope) { this.setStatus(status); this.setResponseHeaders(headers || {}); this.setResponseBody(body || ""); + + this.responseURL = this.url; }, uploadProgress: function uploadProgress(progressEventRaw) { diff --git a/lib/fake-xhr/index.test.js b/lib/fake-xhr/index.test.js index e6bd8b7..bd9eeec 100644 --- a/lib/fake-xhr/index.test.js +++ b/lib/fake-xhr/index.test.js @@ -1907,6 +1907,26 @@ describe("FakeXMLHttpRequest", function() { }); }); + describe(".responseURL", function() { + beforeEach(function() { + this.xhr = new FakeXMLHttpRequest(); + }); + + it("should set responseURL after response", function() { + this.xhr.open("GET", "/"); + + assert.isUndefined(this.xhr.responseURL); + + this.xhr.send(); + + assert.isUndefined(this.xhr.responseURL); + + this.xhr.respond(200, {}, ""); + + assert.equals(this.xhr.responseURL, "/"); + }); + }); + describe("stub XHR", function() { beforeEach(fakeXhrSetUp); afterEach(fakeXhrTearDown);