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

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

Issue 1295573002: Address test slowness with Cache Storage match()/matchAll() tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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
Index: LayoutTests/http/tests/cachestorage/script-tests/cache-match.js
diff --git a/LayoutTests/http/tests/cachestorage/script-tests/cache-match.js b/LayoutTests/http/tests/cachestorage/script-tests/cache-match.js
index b5e5a8c04630e0085d7ea06829a3567b4e5159bb..4c9ce2d6ef2c5076c20d8dd398c3ccea7aebd79d 100644
--- a/LayoutTests/http/tests/cachestorage/script-tests/cache-match.js
+++ b/LayoutTests/http/tests/cachestorage/script-tests/cache-match.js
@@ -4,136 +4,6 @@ if (self.importScripts) {
importScripts('../resources/test-helpers.js');
}
-// A set of Request/Response pairs to be used with prepopulated_cache_test().
-var simple_entries = [
- {
- name: 'a',
- request: new Request('http://example.com/a'),
- response: new Response('')
- },
-
- {
- name: 'b',
- request: new Request('http://example.com/b'),
- response: new Response('')
- },
-
- {
- name: 'a_with_query',
- request: new Request('http://example.com/a?q=r'),
- response: new Response('')
- },
-
- {
- name: 'A',
- request: new Request('http://example.com/A'),
- response: new Response('')
- },
-
- {
- name: 'a_https',
- request: new Request('https://example.com/a'),
- response: new Response('')
- },
-
- {
- name: 'a_org',
- request: new Request('http://example.org/a'),
- response: new Response('')
- },
-
- {
- name: 'cat',
- request: new Request('http://example.com/cat'),
- response: new Response('')
- },
-
- {
- name: 'catmandu',
- request: new Request('http://example.com/catmandu'),
- response: new Response('')
- },
-
- {
- name: 'cat_num_lives',
- request: new Request('http://example.com/cat?lives=9'),
- response: new Response('')
- },
-
- {
- name: 'cat_in_the_hat',
- request: new Request('http://example.com/cat/in/the/hat'),
- response: new Response('')
- },
-
- {
- name: 'secret_cat',
- request: new Request('http://tom:jerry@example.com/cat'),
- response: new Response('')
- },
-
- {
- name: 'top_secret_cat',
- request: new Request('http://tom:j3rry@example.com/cat'),
- response: new Response('')
- },
- {
- name: 'non_2xx_response',
- request: new Request('http://example.com/non2xx'),
- response: new Response('', {status: 404, statusText: 'nope'})
- },
-
- {
- name: 'error_response',
- request: new Request('http://example.com/error'),
- response: Response.error()
- },
-];
-
-// A set of Request/Response pairs to be used with prepopulated_cache_test().
-// These contain a mix of test cases that use Vary headers.
-var vary_entries = [
- {
- name: 'vary_cookie_is_cookie',
- request: new Request('http://example.com/c',
- {headers: {'Cookies': 'is-for-cookie'}}),
- response: new Response('',
- {headers: {'Vary': 'Cookies'}})
- },
-
- {
- name: 'vary_cookie_is_good',
- request: new Request('http://example.com/c',
- {headers: {'Cookies': 'is-good-enough-for-me'}}),
- response: new Response('',
- {headers: {'Vary': 'Cookies'}})
- },
-
- {
- name: 'vary_cookie_absent',
- request: new Request('http://example.com/c'),
- response: new Response('',
- {headers: {'Vary': 'Cookies'}})
- },
-
- {
- name: 'vary_wildcard',
- request: new Request('http://example.com/c',
- {headers: {'Cookies': 'x', 'X-Key': '1'}}),
- response: new Response('',
- {headers: {'Vary': '*'}})
- }
-];
-
-prepopulated_cache_test(simple_entries, function(cache, entries) {
- return cache.matchAll('not-present-in-the-cache')
- .then(function(result) {
- assert_array_equivalent(
- result, [],
- 'Cache.matchAll should resolve with an empty array on failure.');
- });
- }, 'Cache.matchAll with no matching entries');
-
prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match('not-present-in-the-cache')
.then(function(result) {
@@ -143,14 +13,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
}, 'Cache.match with no matching entries');
prepopulated_cache_test(simple_entries, function(cache, entries) {
- return cache.matchAll(entries.a.request.url)
- .then(function(result) {
- assert_array_equivalent(result, [entries.a.response],
- 'Cache.matchAll should match by URL.');
- });
- }, 'Cache.matchAll with URL');
-
-prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.a.request.url)
.then(function(result) {
assert_object_equals_fixed(result, entries.a.response,
@@ -159,14 +21,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
}, 'Cache.match with URL');
prepopulated_cache_test(simple_entries, function(cache, entries) {
- return cache.matchAll(entries.a.request)
- .then(function(result) {
- assert_array_equivalent(result, [entries.a.response],
- 'Cache.matchAll should match by Request.');
- });
- }, 'Cache.matchAll with Request');
-
-prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.a.request)
.then(function(result) {
assert_object_equals_fixed(result, entries.a.response,
@@ -175,14 +29,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
}, 'Cache.match with Request');
prepopulated_cache_test(simple_entries, function(cache, entries) {
- return cache.matchAll(new Request(entries.a.request.url))
- .then(function(result) {
- assert_array_equivalent(result, [entries.a.response],
- 'Cache.matchAll should match by Request.');
- });
- }, 'Cache.matchAll with new Request');
-
-prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(new Request(entries.a.request.url))
.then(function(result) {
assert_object_equals_fixed(result, entries.a.response,
@@ -191,23 +37,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
}, 'Cache.match with new Request');
prepopulated_cache_test(simple_entries, function(cache, entries) {
- return cache.matchAll(entries.a.request,
- {ignoreSearch: true})
- .then(function(result) {
- assert_array_equivalent(
- result,
- [
- entries.a.response,
- entries.a_with_query.response
- ],
- 'Cache.matchAll with ignoreSearch should ignore the ' +
- 'search parameters of cached request.');
- });
- },
- 'Cache.matchAll with ignoreSearch option (request with no search ' +
- 'parameters)');
-
-prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.a.request,
{ignoreSearch: true})
.then(function(result) {
@@ -225,22 +54,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
'parameters)');
prepopulated_cache_test(simple_entries, function(cache, entries) {
- return cache.matchAll(entries.a_with_query.request,
- {ignoreSearch: true})
- .then(function(result) {
- assert_array_equivalent(
- result,
- [
- entries.a.response,
- entries.a_with_query.response
- ],
- 'Cache.matchAll with ignoreSearch should ignore the ' +
- 'search parameters of request.');
- });
- },
- 'Cache.matchAll with ignoreSearch option (request with search parameter)');
-
-prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.a_with_query.request,
{ignoreSearch: true})
.then(function(result) {
@@ -257,18 +70,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
'Cache.match with ignoreSearch option (request with search parameter)');
prepopulated_cache_test(simple_entries, function(cache, entries) {
- return cache.matchAll(entries.cat.request.url + '#mouse')
- .then(function(result) {
- assert_array_equivalent(
- result,
- [
- entries.cat.response,
- ],
- 'Cache.matchAll should ignore URL fragment.');
- });
- }, 'Cache.matchAll with URL containing fragment');
-
-prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.cat.request.url + '#mouse')
.then(function(result) {
assert_object_equals_fixed(result, entries.cat.response,
@@ -277,16 +78,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
}, 'Cache.match with URL containing fragment');
prepopulated_cache_test(simple_entries, function(cache, entries) {
- return cache.matchAll('http')
- .then(function(result) {
- assert_array_equivalent(
- result, [],
- 'Cache.matchAll should treat query as a URL and not ' +
- 'just a string fragment.');
- });
- }, 'Cache.matchAll with string fragment "http" as query');
-
-prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match('http')
.then(function(result) {
assert_equals(
@@ -297,15 +88,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
}, 'Cache.match with string fragment "http" as query');
prepopulated_cache_test(simple_entries, function(cache, entries) {
- return cache.matchAll(entries.secret_cat.request.url)
- .then(function(result) {
- assert_array_equivalent(
- result, [entries.secret_cat.response],
- 'Cache.matchAll should not ignore embedded credentials');
- });
- }, 'Cache.matchAll with URL containing credentials');
-
-prepopulated_cache_test(simple_entries, function(cache, entries) {
return cache.match(entries.secret_cat.request.url)
.then(function(result) {
assert_object_equals_fixed(
@@ -315,50 +97,6 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
}, 'Cache.match with URL containing credentials');
prepopulated_cache_test(vary_entries, function(cache, entries) {
- return cache.matchAll('http://example.com/c')
- .then(function(result) {
- assert_array_equivalent(
- result,
- [
- entries.vary_wildcard.response,
- entries.vary_cookie_absent.response
- ],
- 'Cache.matchAll should exclude matches if a vary header is ' +
- 'missing in the query request, but is present in the cached ' +
- 'request.');
- })
-
- .then(function() {
- return cache.matchAll(
- new Request('http://example.com/c',
- {headers: {'Cookies': 'none-of-the-above'}}));
- })
- .then(function(result) {
- assert_array_equivalent(
- result,
- [
- entries.vary_wildcard.response
- ],
- 'Cache.matchAll should exclude matches if a vary header is ' +
- 'missing in the cached request, but is present in the query ' +
- 'request.');
- })
-
- .then(function() {
- return cache.matchAll(
- new Request('http://example.com/c',
- {headers: {'Cookies': 'is-for-cookie'}}));
- })
- .then(function(result) {
- assert_array_equivalent(
- result,
- [entries.vary_cookie_is_cookie.response],
- 'Cache.matchAll should match the entire header if a vary header ' +
- 'is present in both the query and cached requests.');
- });
- }, 'Cache.matchAll with responses containing "Vary" header');
-
-prepopulated_cache_test(vary_entries, function(cache, entries) {
return cache.match('http://example.com/c')
.then(function(result) {
assert_object_in_array(
@@ -371,22 +109,6 @@ prepopulated_cache_test(vary_entries, function(cache, entries) {
});
}, 'Cache.match with responses containing "Vary" header');
-prepopulated_cache_test(vary_entries, function(cache, entries) {
- return cache.matchAll('http://example.com/c',
- {ignoreVary: true})
- .then(function(result) {
- assert_array_equivalent(
- result,
- [
- entries.vary_cookie_is_cookie.response,
- entries.vary_cookie_is_good.response,
- entries.vary_cookie_absent.response,
- entries.vary_wildcard.response
- ],
- 'Cache.matchAll should honor "ignoreVary" parameter.');
- });
- }, 'Cache.matchAll with "ignoreVary" parameter');
-
cache_test(function(cache) {
var request = new Request('http://example.com');
var response;
@@ -478,38 +200,4 @@ prepopulated_cache_test(simple_entries, function(cache, entries) {
});
}, 'Cache.match with a network error Response');
-// Helpers ---
-
-// Run |test_function| with a Cache object as its only parameter. Prior to the
-// call, the Cache is populated by cache entries from |entries|. The latter is
-// expected to be an Object mapping arbitrary keys to objects of the form
-// {request: <Request object>, response: <Response object>}. There's no
-// guarantee on the order in which entries will be added to the cache.
-//
-// |test_function| should return a Promise that can be used with promise_test.
-function prepopulated_cache_test(entries, test_function, description) {
- cache_test(function(cache) {
- var p = Promise.resolve();
- var hash = {};
- entries.forEach(function(entry) {
- p = p.then(function() {
- return cache.put(entry.request.clone(),
- entry.response.clone())
- .catch(function(e) {
- assert_unreached('Test setup failed for entry ' +
- entry.name + ': ' + e);
- });
- });
- hash[entry.name] = entry;
- });
- p = p.then(function() {
- assert_equals(Object.keys(hash).length, entries.length);
- });
-
- return p.then(function() {
- return test_function(cache, hash);
- });
- }, description);
-}
-
done();

Powered by Google App Engine
This is Rietveld 408576698