зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1143219
- Add tests for passing an unknown request to match and matchAll; r=bkelly
This commit is contained in:
Родитель
6d65226133
Коммит
0046a6d6ef
|
@ -1,6 +1,7 @@
|
|||
var request1 = new Request("//mochi.test:8888/?1&" + context);
|
||||
var request2 = new Request("//mochi.test:8888/?2&" + context);
|
||||
var request3 = new Request("//mochi.test:8888/?3&" + context);
|
||||
var unknownRequest = new Request("//mochi.test:8888/non/existing/path?" + context);
|
||||
var response1, response3;
|
||||
var c;
|
||||
var response1Text, response3Text;
|
||||
|
@ -30,15 +31,16 @@ fetch(new Request(request1)).then(function(r) {
|
|||
return response3.text();
|
||||
}).then(function(text) {
|
||||
response3Text = text;
|
||||
return testRequest(request1, request2, request3);
|
||||
return testRequest(request1, request2, request3, unknownRequest);
|
||||
}).then(function() {
|
||||
return testRequest(request1.url, request2.url, request3.url);
|
||||
return testRequest(request1.url, request2.url, request3.url,
|
||||
unknownRequest.url);
|
||||
}).then(function() {
|
||||
testDone();
|
||||
});
|
||||
|
||||
// The request arguments can either be a URL string, or a Request object.
|
||||
function testRequest(request1, request2, request3) {
|
||||
function testRequest(request1, request2, request3, unknownRequest) {
|
||||
return caches.open(name).then(function(cache) {
|
||||
c = cache;
|
||||
return c.add(request1);
|
||||
|
@ -67,6 +69,12 @@ function testRequest(request1, request2, request3) {
|
|||
}).catch(function(err) {
|
||||
is(err.name, "NotFoundError", "Searching in the wrong cache should not succeed");
|
||||
}).then(function() {
|
||||
return c.matchAll(unknownRequest);
|
||||
}).then(function(r) {
|
||||
is(r.length, 0, "Searching for an unknown request should not succeed");
|
||||
return c.matchAll(unknownRequest, {cacheName: name});
|
||||
}).then(function(r) {
|
||||
is(r.length, 0, "Searching for an unknown request should not succeed");
|
||||
return caches.delete(name);
|
||||
}).then(function(success) {
|
||||
ok(success, "We should be able to delete the cache successfully");
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var request = new Request("//mochi.test:8888/?" + context);
|
||||
var unknownRequest = new Request("//mochi.test:8888/non/existing/path?" + context);
|
||||
var response;
|
||||
var c;
|
||||
var responseText;
|
||||
|
@ -22,15 +23,15 @@ fetch(new Request(request)).then(function(r) {
|
|||
return response.text();
|
||||
}).then(function(text) {
|
||||
responseText = text;
|
||||
return testRequest(request);
|
||||
return testRequest(request, unknownRequest);
|
||||
}).then(function() {
|
||||
return testRequest(request.url);
|
||||
return testRequest(request.url, unknownRequest.url);
|
||||
}).then(function() {
|
||||
testDone();
|
||||
});
|
||||
|
||||
// The request argument can either be a URL string, or a Request object.
|
||||
function testRequest(request) {
|
||||
function testRequest(request, unknownRequest) {
|
||||
return caches.open(name).then(function(cache) {
|
||||
c = cache;
|
||||
return c.add(request);
|
||||
|
@ -51,6 +52,15 @@ function testRequest(request) {
|
|||
}).catch(function(err) {
|
||||
is(err.name, "NotFoundError", "Searching in the wrong cache should not succeed");
|
||||
}).then(function() {
|
||||
return c.match(unknownRequest);
|
||||
}).then(function(r) {
|
||||
is(typeof r, "undefined", "Searching for an unknown request should not succeed");
|
||||
return caches.match(unknownRequest);
|
||||
}).then(function(r) {
|
||||
is(typeof r, "undefined", "Searching for an unknown request should not succeed");
|
||||
return caches.match(unknownRequest, {cacheName: name});
|
||||
}).then(function(r) {
|
||||
is(typeof r, "undefined", "Searching for an unknown request should not succeed");
|
||||
return caches.delete(name);
|
||||
}).then(function(success) {
|
||||
ok(success, "We should be able to delete the cache successfully");
|
||||
|
|
Загрузка…
Ссылка в новой задаче