Index: LayoutTests/http/tests/cachestorage/script-tests/cache-add.js |
diff --git a/LayoutTests/http/tests/cachestorage/script-tests/cache-add.js b/LayoutTests/http/tests/cachestorage/script-tests/cache-add.js |
index 6b11e5a0c51061c1d19991263f7d480c7a464cd1..205eb885477a50a777341c6d1e88ba72a178e853 100644 |
--- a/LayoutTests/http/tests/cachestorage/script-tests/cache-add.js |
+++ b/LayoutTests/http/tests/cachestorage/script-tests/cache-add.js |
@@ -98,42 +98,118 @@ cache_test(function(cache) { |
}, 'Cache.addAll with a mix of valid and undefined arguments'); |
cache_test(function(cache) { |
- // Assumes the existence of ../resources/simple.txt and ../resources/blank.html |
- var urls = ['../resources/simple.txt', self.location.href, '../resources/blank.html']; |
+ // Assumes the existence of ../resources/simple.txt and |
+ // ../resources/blank.html |
+ var urls = ['../resources/simple.txt', |
+ self.location.href, |
+ '../resources/blank.html']; |
return cache.addAll(urls) |
.then(function(result) { |
assert_equals(result, undefined, |
'Cache.addAll should resolve with undefined on ' + |
'success.'); |
+ return Promise.all( |
+ urls.map(function(url) { return cache.match(url); })); |
+ }) |
+ .then(function(responses) { |
+ assert_class_string( |
+ responses[0], 'Response', |
+ 'Cache.addAll should put a resource in the cache.'); |
+ assert_class_string( |
+ responses[1], 'Response', |
+ 'Cache.addAll should put a resource in the cache.'); |
+ assert_class_string( |
+ responses[2], 'Response', |
+ 'Cache.addAll should put a resource in the cache.'); |
+ return Promise.all( |
+ responses.map(function(response) { return response.text(); })); |
+ }) |
+ .then(function(bodies) { |
+ assert_equals( |
+ bodies[0], 'a simple text file\n', |
+ 'Cache.add should retrieve the correct body.'); |
+ assert_equals( |
+ bodies[2], '<!DOCTYPE html>\n<title>Empty doc</title>\n', |
+ 'Cache.add should retrieve the correct body.'); |
}); |
}, 'Cache.addAll with string URL arguments'); |
cache_test(function(cache) { |
- // Assumes the existence of ../resources/simple.txt and ../resources/blank.html |
- var urls = ['../resources/simple.txt', self.location.href, '../resources/blank.html']; |
- var requests = urls.map(function(url) { |
- return new Request(url); |
- }); |
+ // Assumes the existence of ../resources/simple.txt and |
+ // ../resources/blank.html |
+ var urls = ['../resources/simple.txt', |
+ self.location.href, |
+ '../resources/blank.html']; |
+ var requests = urls.map(function(url) { return new Request(url); }); |
return cache.addAll(requests) |
.then(function(result) { |
assert_equals(result, undefined, |
'Cache.addAll should resolve with undefined on ' + |
'success.'); |
+ return Promise.all( |
+ urls.map(function(url) { return cache.match(url); })); |
+ }) |
+ .then(function(responses) { |
+ assert_class_string( |
+ responses[0], 'Response', |
+ 'Cache.addAll should put a resource in the cache.'); |
+ assert_class_string( |
+ responses[1], 'Response', |
+ 'Cache.addAll should put a resource in the cache.'); |
+ assert_class_string( |
+ responses[2], 'Response', |
+ 'Cache.addAll should put a resource in the cache.'); |
+ return Promise.all( |
+ responses.map(function(response) { return response.text(); })); |
+ }) |
+ .then(function(bodies) { |
+ assert_equals( |
+ bodies[0], 'a simple text file\n', |
+ 'Cache.add should retrieve the correct body.'); |
+ assert_equals( |
+ bodies[2], '<!DOCTYPE html>\n<title>Empty doc</title>\n', |
+ 'Cache.add should retrieve the correct body.'); |
}); |
}, 'Cache.addAll with Request arguments'); |
cache_test(function(cache) { |
- // Assumes that ../resources/simple.txt and ../resources/blank.html exist. The second |
- // resource does not. |
- var urls = ['../resources/simple.txt', 'this-resource-should-not-exist', '../resources/blank.html']; |
- var requests = urls.map(function(url) { |
- return new Request(url); |
- }); |
+ // Assumes that ../resources/simple.txt and ../resources/blank.html exist. |
+ // The second resource does not. |
+ var urls = ['../resources/simple.txt', |
+ 'this-resource-should-not-exist', |
+ '../resources/blank.html']; |
+ var requests = urls.map(function(url) { return new Request(url); }); |
return cache.addAll(requests) |
.then(function(result) { |
assert_equals(result, undefined, |
'Cache.addAll should resolve with undefined on ' + |
'success.'); |
+ return Promise.all( |
+ urls.map(function(url) { return cache.match(url); })); |
+ }) |
+ .then(function(responses) { |
+ assert_class_string( |
+ responses[0], 'Response', |
+ 'Cache.addAll should put a resource in the cache.'); |
+ assert_class_string( |
+ responses[1], 'Response', |
+ 'Cache.addAll should put a resource in the cache.'); |
+ assert_equals( |
+ responses[1].status, 404, |
+ 'Cache.addAll should put a 404 resource in the cache.'); |
+ assert_class_string( |
+ responses[2], 'Response', |
+ 'Cache.addAll should put a resource in the cache.'); |
+ return Promise.all( |
+ responses.map(function(response) { return response.text(); })); |
+ }) |
+ .then(function(bodies) { |
+ assert_equals( |
+ bodies[0], 'a simple text file\n', |
+ 'Cache.add should retrieve the correct body.'); |
+ assert_equals( |
+ bodies[2], '<!DOCTYPE html>\n<title>Empty doc</title>\n', |
+ 'Cache.add should retrieve the correct body.'); |
}); |
}, 'Cache.addAll with a mix of succeeding and failing requests'); |