Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: LayoutTests/http/tests/cachestorage/script-tests/cache-add.js

Issue 1124403005: CacheStorage: Implement Cache.addAll() behind a flag (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix test failure Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/cachestorage/serviceworker/cache-add-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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');
« no previous file with comments | « no previous file | LayoutTests/http/tests/cachestorage/serviceworker/cache-add-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698