Commit 1889c010 authored by jsbell@chromium.org's avatar jsbell@chromium.org

Address test slowness with Cache Storage match()/matchAll() tests

The test cases initially ran in parallel, but the web-platform-tests'
promise_test() switched to running cases serially for predictability,
which made these tests with many cases and lots of setup time out.

* Split up the match() and matchAll() tests into separate files
* Do the pre-population of the caches (within each test) in parallel

BUG=508984

Review URL: https://codereview.chromium.org/1295573002

git-svn-id: svn://svn.chromium.org/blink/trunk@200754 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 91a53cdb
......@@ -217,7 +217,3 @@ crbug.com/459009 crypto/subtle/ [ Slow ]
crbug.com/24182 [ Debug ] animations/interpolation/transform-interpolation.html [ Slow ]
crbug.com/24182 [ Debug ] animations/interpolation/webkit-transform-interpolation.html [ Slow ]
crbug.com/508984 http/tests/cachestorage/serviceworker/cache-match.html [ Slow ]
crbug.com/508984 http/tests/cachestorage/worker/cache-match.html [ Slow ]
crbug.com/508984 http/tests/cachestorage/window/cache-match.html [ Slow ]
......@@ -35,3 +35,153 @@ function cache_test(test_function, description) {
.then(test_function);
}, description);
}
// 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': '*'}})
}
];
// Run |test_function| with a Cache object and a map of entries. 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 = {};
return Promise.all(entries.map(function(entry) {
hash[entry.name] = entry;
return cache.put(entry.request.clone(),
entry.response.clone())
.catch(function(e) {
assert_unreached(
'Test setup failed for entry ' + entry.name + ': ' + e);
});
}))
.then(function() {
assert_equals(Object.keys(hash).length, entries.length);
})
.then(function() {
return test_function(cache, hash);
});
}, description);
}
if (self.importScripts) {
importScripts('/resources/testharness.js');
importScripts('/resources/testharness-helpers.js');
importScripts('../resources/test-helpers.js');
}
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.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.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.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.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.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.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.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.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(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.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');
done();
This is a testharness.js-based test.
PASS Cache.match and Cache.matchAll
PASS Cache.matchAll with no matching entries
PASS Cache.match
PASS Cache.match with no matching entries
PASS Cache.matchAll with URL
PASS Cache.match with URL
PASS Cache.matchAll with Request
PASS Cache.match with Request
PASS Cache.matchAll with new Request
PASS Cache.match with new Request
FAIL Cache.matchAll with ignoreSearch option (request with no search parameters) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of cached request. expected 2 but got 1
PASS Cache.match with ignoreSearch option (request with no search parameters)
FAIL Cache.matchAll with ignoreSearch option (request with search parameter) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of request. expected 2 but got 1
PASS Cache.match with ignoreSearch option (request with search parameter)
PASS Cache.matchAll with URL containing fragment
PASS Cache.match with URL containing fragment
PASS Cache.matchAll with string fragment "http" as query
PASS Cache.match with string fragment "http" as query
PASS Cache.matchAll with URL containing credentials
PASS Cache.match with URL containing credentials
FAIL Cache.matchAll with responses containing "Vary" header assert_equals: Cache.matchAll should exclude matches if a vary header is missing in the query request, but is present in the cached request. expected 2 but got 0
FAIL Cache.match with responses containing "Vary" header assert_true: Cache.match should honor "Vary" header. expected true got false
FAIL Cache.matchAll with "ignoreVary" parameter assert_equals: Cache.matchAll should honor "ignoreVary" parameter. expected 4 but got 0
PASS Cache.match with Request and Response objects with different URLs
PASS Cache.match invoked multiple times for the same Request/Response
FAIL Cache.match with POST Request assert_equals: Cache.match should not find a match expected (undefined) undefined but got (object) object "[object Response]"
......
<!DOCTYPE html>
<title>Cache.match and Cache.matchAll</title>
<title>Cache.match</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-match">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
......
This is a testharness.js-based test.
PASS Cache.matchAll
PASS Cache.matchAll with no matching entries
PASS Cache.matchAll with URL
PASS Cache.matchAll with Request
PASS Cache.matchAll with new Request
FAIL Cache.matchAll with ignoreSearch option (request with no search parameters) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of cached request. expected 2 but got 1
FAIL Cache.matchAll with ignoreSearch option (request with search parameter) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of request. expected 2 but got 1
PASS Cache.matchAll with URL containing fragment
PASS Cache.matchAll with string fragment "http" as query
PASS Cache.matchAll with URL containing credentials
FAIL Cache.matchAll with responses containing "Vary" header assert_equals: Cache.matchAll should exclude matches if a vary header is missing in the query request, but is present in the cached request. expected 2 but got 0
FAIL Cache.matchAll with "ignoreVary" parameter assert_equals: Cache.matchAll should honor "ignoreVary" parameter. expected 4 but got 0
Harness: the test ran to completion.
<!DOCTYPE html>
<title>Cache.matchAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-matchall">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../serviceworker/resources/test-helpers.js"></script>
<script>
service_worker_test('../script-tests/cache-matchAll.js');
</script>
This is a testharness.js-based test.
PASS Cache.matchAll with no matching entries
PASS Cache.match with no matching entries
PASS Cache.matchAll with URL
PASS Cache.match with URL
PASS Cache.matchAll with Request
PASS Cache.match with Request
PASS Cache.matchAll with new Request
PASS Cache.match with new Request
FAIL Cache.matchAll with ignoreSearch option (request with no search parameters) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of cached request. expected 2 but got 1
PASS Cache.match with ignoreSearch option (request with no search parameters)
FAIL Cache.matchAll with ignoreSearch option (request with search parameter) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of request. expected 2 but got 1
PASS Cache.match with ignoreSearch option (request with search parameter)
PASS Cache.matchAll with URL containing fragment
PASS Cache.match with URL containing fragment
PASS Cache.matchAll with string fragment "http" as query
PASS Cache.match with string fragment "http" as query
PASS Cache.matchAll with URL containing credentials
PASS Cache.match with URL containing credentials
FAIL Cache.matchAll with responses containing "Vary" header assert_equals: Cache.matchAll should exclude matches if a vary header is missing in the query request, but is present in the cached request. expected 2 but got 0
FAIL Cache.match with responses containing "Vary" header assert_true: Cache.match should honor "Vary" header. expected true got false
FAIL Cache.matchAll with "ignoreVary" parameter assert_equals: Cache.matchAll should honor "ignoreVary" parameter. expected 4 but got 0
PASS Cache.match with Request and Response objects with different URLs
PASS Cache.match invoked multiple times for the same Request/Response
FAIL Cache.match with POST Request assert_equals: Cache.match should not find a match expected (undefined) undefined but got (object) object "[object Response]"
......
<!DOCTYPE html>
<title>Cache Storage: Cache.match and Cache.matchAll</title>
<title>Cache Storage: Cache.match</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-match">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
......
This is a testharness.js-based test.
PASS Cache.matchAll with no matching entries
PASS Cache.matchAll with URL
PASS Cache.matchAll with Request
PASS Cache.matchAll with new Request
FAIL Cache.matchAll with ignoreSearch option (request with no search parameters) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of cached request. expected 2 but got 1
FAIL Cache.matchAll with ignoreSearch option (request with search parameter) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of request. expected 2 but got 1
PASS Cache.matchAll with URL containing fragment
PASS Cache.matchAll with string fragment "http" as query
PASS Cache.matchAll with URL containing credentials
FAIL Cache.matchAll with responses containing "Vary" header assert_equals: Cache.matchAll should exclude matches if a vary header is missing in the query request, but is present in the cached request. expected 2 but got 0
FAIL Cache.matchAll with "ignoreVary" parameter assert_equals: Cache.matchAll should honor "ignoreVary" parameter. expected 4 but got 0
Harness: the test ran to completion.
<!DOCTYPE html>
<title>Cache Storage: Cache.matchAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-matchall">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testharness-helpers.js"></script>
<script src="../resources/test-helpers.js"></script>
<script src="../script-tests/cache-matchAll.js"></script>
This is a testharness.js-based test.
PASS Cache.matchAll with no matching entries
PASS Cache.match with no matching entries
PASS Cache.matchAll with URL
PASS Cache.match with URL
PASS Cache.matchAll with Request
PASS Cache.match with Request
PASS Cache.matchAll with new Request
PASS Cache.match with new Request
FAIL Cache.matchAll with ignoreSearch option (request with no search parameters) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of cached request. expected 2 but got 1
PASS Cache.match with ignoreSearch option (request with no search parameters)
FAIL Cache.matchAll with ignoreSearch option (request with search parameter) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of request. expected 2 but got 1
PASS Cache.match with ignoreSearch option (request with search parameter)
PASS Cache.matchAll with URL containing fragment
PASS Cache.match with URL containing fragment
PASS Cache.matchAll with string fragment "http" as query
PASS Cache.match with string fragment "http" as query
PASS Cache.matchAll with URL containing credentials
PASS Cache.match with URL containing credentials
FAIL Cache.matchAll with responses containing "Vary" header assert_equals: Cache.matchAll should exclude matches if a vary header is missing in the query request, but is present in the cached request. expected 2 but got 0
FAIL Cache.match with responses containing "Vary" header assert_true: Cache.match should honor "Vary" header. expected true got false
FAIL Cache.matchAll with "ignoreVary" parameter assert_equals: Cache.matchAll should honor "ignoreVary" parameter. expected 4 but got 0
PASS Cache.match with Request and Response objects with different URLs
PASS Cache.match invoked multiple times for the same Request/Response
FAIL Cache.match with POST Request assert_equals: Cache.match should not find a match expected (undefined) undefined but got (object) object "[object Response]"
......
<!DOCTYPE html>
<title>Cache.match and Cache.matchAll</title>
<title>Cache.match</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-match">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
......
This is a testharness.js-based test.
PASS Cache.matchAll with no matching entries
PASS Cache.matchAll with URL
PASS Cache.matchAll with Request
PASS Cache.matchAll with new Request
FAIL Cache.matchAll with ignoreSearch option (request with no search parameters) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of cached request. expected 2 but got 1
FAIL Cache.matchAll with ignoreSearch option (request with search parameter) assert_equals: Cache.matchAll with ignoreSearch should ignore the search parameters of request. expected 2 but got 1
PASS Cache.matchAll with URL containing fragment
PASS Cache.matchAll with string fragment "http" as query
PASS Cache.matchAll with URL containing credentials
FAIL Cache.matchAll with responses containing "Vary" header assert_equals: Cache.matchAll should exclude matches if a vary header is missing in the query request, but is present in the cached request. expected 2 but got 0
FAIL Cache.matchAll with "ignoreVary" parameter assert_equals: Cache.matchAll should honor "ignoreVary" parameter. expected 4 but got 0
Harness: the test ran to completion.
<!DOCTYPE html>
<title>Cache.matchAll</title>
<link rel="help" href="https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#cache-matchall">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
fetch_tests_from_worker(new Worker('../script-tests/cache-matchAll.js'));
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment