Fix headers in modern browsers.

This commit is contained in:
nobuti 2016-09-30 15:48:24 +02:00
parent d9b9b325c4
commit 7b1047a4b6
5 changed files with 74 additions and 39 deletions

View File

@ -1,41 +1,44 @@
GEM
remote: https://rubygems.org/
specs:
childprocess (0.5.3)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
cmdparse (2.0.6)
ffi (1.9.3)
highline (1.6.21)
jasmine (2.0.2)
cmdparse (3.0.1)
domain_name (0.5.20160826)
unf (>= 0.0.5, < 1.0.0)
ffi (1.9.14)
highline (1.7.8)
http-cookie (1.0.3)
domain_name (~> 0.5)
jasmine (2.0.3)
jasmine-core (~> 2.0.0)
phantomjs
rack (>= 1.2.1)
rake
jasmine-core (2.0.1)
jasmine_selenium_runner (0.2.0)
jasmine (~> 2.0.0.alpha)
jasmine-core (2.0.2)
jasmine_selenium_runner (2.4.0)
jasmine (~> 2.0)
sauce-connect
selenium-webdriver (~> 2.35)
json (1.8.1)
mime-types (1.25.1)
multi_json (1.10.1)
json (1.8.3)
mime-types (2.99.3)
net-http-persistent (2.9.4)
net-ssh (2.9.1)
net-ssh (3.2.0)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
parallel (1.1.2)
parallel_tests (0.16.6)
netrc (0.11.0)
parallel (1.9.0)
parallel_tests (1.3.7)
parallel
phantomjs (1.9.7.1)
rack (1.5.2)
rake (10.3.2)
rdoc (4.1.1)
json (~> 1.4)
rest-client (1.6.8)
mime-types (~> 1.16)
rdoc (>= 2.4.2)
rubyzip (1.1.6)
sauce (3.4.9)
phantomjs (2.1.1.0)
rack (2.0.1)
rake (11.3.0)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rubyzip (1.2.0)
sauce (3.7.1)
childprocess (>= 0.1.6)
cmdparse (>= 2.0.2)
highline (>= 1.5.0)
@ -43,21 +46,23 @@ GEM
net-http-persistent
net-ssh
net-ssh-gateway
parallel_tests (= 0.16.6)
parallel_tests (>= 1.1.1, <= 1.3.7)
rest-client
sauce_whisk (~> 0.0.11)
selenium-webdriver (>= 0.1.2)
sauce-connect (3.4.1)
sauce (~> 3.4)
sauce_whisk (0.0.13)
sauce-connect (3.6.2)
sauce (~> 3.5)
sauce_whisk (0.0.21)
json (~> 1.8.1)
rest-client (~> 1.6.7)
selenium-webdriver (2.42.0)
childprocess (>= 0.5.0)
multi_json (~> 1.0)
rest-client (~> 1.8.0)
selenium-webdriver (2.53.4)
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0.4)
websocket (1.0.7)
websocket (~> 1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
websocket (1.2.3)
PLATFORMS
ruby
@ -68,4 +73,4 @@ DEPENDENCIES
rake
BUNDLED WITH
1.10.1
1.12.2

View File

@ -384,8 +384,12 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
},
getResponseHeader: function(name) {
var resultHeader = null;
if (!this.responseHeaders) {
return resultHeader;
}
name = name.toLowerCase();
var resultHeader;
for(var i = 0; i < this.responseHeaders.length; i++) {
var header = this.responseHeaders[i];
if (name === header.name.toLowerCase()) {
@ -400,6 +404,10 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
},
getAllResponseHeaders: function() {
if (!this.responseHeaders) {
return null;
}
var responseHeaders = [];
for (var i = 0; i < this.responseHeaders.length; i++) {
responseHeaders.push(this.responseHeaders[i].name + ': ' +

View File

@ -112,6 +112,16 @@ describe('FakeRequest', function() {
expect(request.requestHeaders).toEqual({});
});
it('getResponseHeader returns null, if no response has been received', function() {
var request = new this.FakeRequest();
expect(request.getResponseHeader('XY')).toBe(null);
});
it('getAllResponseHeaders returns null, if no response has been received', function() {
var request = new this.FakeRequest();
expect(request.getAllResponseHeaders()).toBe(null);
});
describe('managing readyState', function() {
beforeEach(function() {
this.request = new this.FakeRequest();

View File

@ -321,6 +321,10 @@ describe("Jasmine Mock Ajax (for toplevel)", function() {
expect(response.getResponseHeader('X-Header')).toBe('header value 1, header value 2');
});
it("returns null, if header does not exist", function() {
expect(response.getResponseHeader('X-Does-Not-Exist')).toBe(null);
});
it("getAllResponseHeaders should return all values", function () {
expect(response.getAllResponseHeaders()).toBe([
"X-Header: header value 1",

View File

@ -207,8 +207,12 @@ extend(FakeXMLHttpRequest, {
},
getResponseHeader: function(name) {
var resultHeader = null;
if (!this.responseHeaders) {
return resultHeader;
}
name = name.toLowerCase();
var resultHeader;
for(var i = 0; i < this.responseHeaders.length; i++) {
var header = this.responseHeaders[i];
if (name === header.name.toLowerCase()) {
@ -223,6 +227,10 @@ extend(FakeXMLHttpRequest, {
},
getAllResponseHeaders: function() {
if (!this.responseHeaders) {
return null;
}
var responseHeaders = [];
for (var i = 0; i < this.responseHeaders.length; i++) {
responseHeaders.push(this.responseHeaders[i].name + ': ' +