Bug 1144236 - Add tests for the ignoreMethod match mode in DOM cache; r=bkelly

This commit is contained in:
Ehsan Akhgari 2015-03-17 13:57:52 -04:00
parent 58dbbe9814
commit 2b77f254df
2 changed files with 38 additions and 0 deletions

View File

@ -74,6 +74,26 @@ function testRequest(request1, request2, request3, unknownRequest,
}).then(function(r) {
is(r.length, 1, "Should only find 1 item");
return checkResponse(r[0], response1, response1Text);
}).then(function() {
return c.matchAll(new Request(request1, {method: "HEAD"}));
}).then(function(r) {
is(r.length, 1, "Should only find 1 item");
return checkResponse(r[0], response1, response1Text);
}).then(function() {
return Promise.all(
["POST", "PUT", "DELETE", "OPTIONS"]
.map(function(method) {
var req = new Request(request1, {method: method});
return c.matchAll(req)
.then(function(r) {
is(r.length, 0, "Searching for a request with a non-GET/HEAD method should not succeed");
return c.matchAll(req, {ignoreMethod: true});
}).then(function(r) {
is(r.length, 1, "Should only find 1 item");
return checkResponse(r[0], response1, response1Text);
});
})
);
}).then(function() {
return c.matchAll(requestWithDifferentFragment);
}).then(function(r) {

View File

@ -60,6 +60,24 @@ function testRequest(request, unknownRequest, requestWithAlternateQueryString,
return c.match(request);
}).then(function(r) {
return checkResponse(r);
}).then(function() {
return c.match(new Request(request, {method: "HEAD"}));
}).then(function(r) {
return checkResponse(r);
}).then(function() {
return Promise.all(
["POST", "PUT", "DELETE", "OPTIONS"]
.map(function(method) {
var req = new Request(request, {method: method});
return c.match(req)
.then(function(r) {
is(typeof r, "undefined", "Searching for a request with a non-GET/HEAD method should not succeed");
return c.match(req, {ignoreMethod: true});
}).then(function(r) {
return checkResponse(r);
});
})
);
}).then(function() {
return caches.match(request);
}).then(function(r) {