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

Side by Side Diff: LayoutTests/http/tests/cachestorage/script-tests/cache-matchAll.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 if (self.importScripts) {
2 importScripts('/resources/testharness.js');
3 importScripts('/resources/testharness-helpers.js');
4 importScripts('../resources/test-helpers.js');
5 }
6
7 prepopulated_cache_test(simple_entries, function(cache, entries) {
8 return cache.matchAll('not-present-in-the-cache')
9 .then(function(result) {
10 assert_array_equivalent(
11 result, [],
12 'Cache.matchAll should resolve with an empty array on failure.');
13 });
14 }, 'Cache.matchAll with no matching entries');
15
16 prepopulated_cache_test(simple_entries, function(cache, entries) {
17 return cache.matchAll(entries.a.request.url)
18 .then(function(result) {
19 assert_array_equivalent(result, [entries.a.response],
20 'Cache.matchAll should match by URL.');
21 });
22 }, 'Cache.matchAll with URL');
23
24 prepopulated_cache_test(simple_entries, function(cache, entries) {
25 return cache.matchAll(entries.a.request)
26 .then(function(result) {
27 assert_array_equivalent(result, [entries.a.response],
28 'Cache.matchAll should match by Request.');
29 });
30 }, 'Cache.matchAll with Request');
31
32 prepopulated_cache_test(simple_entries, function(cache, entries) {
33 return cache.matchAll(new Request(entries.a.request.url))
34 .then(function(result) {
35 assert_array_equivalent(result, [entries.a.response],
36 'Cache.matchAll should match by Request.');
37 });
38 }, 'Cache.matchAll with new Request');
39
40 prepopulated_cache_test(simple_entries, function(cache, entries) {
41 return cache.matchAll(entries.a.request,
42 {ignoreSearch: true})
43 .then(function(result) {
44 assert_array_equivalent(
45 result,
46 [
47 entries.a.response,
48 entries.a_with_query.response
49 ],
50 'Cache.matchAll with ignoreSearch should ignore the ' +
51 'search parameters of cached request.');
52 });
53 },
54 'Cache.matchAll with ignoreSearch option (request with no search ' +
55 'parameters)');
56
57 prepopulated_cache_test(simple_entries, function(cache, entries) {
58 return cache.matchAll(entries.a_with_query.request,
59 {ignoreSearch: true})
60 .then(function(result) {
61 assert_array_equivalent(
62 result,
63 [
64 entries.a.response,
65 entries.a_with_query.response
66 ],
67 'Cache.matchAll with ignoreSearch should ignore the ' +
68 'search parameters of request.');
69 });
70 },
71 'Cache.matchAll with ignoreSearch option (request with search parameter)');
72
73 prepopulated_cache_test(simple_entries, function(cache, entries) {
74 return cache.matchAll(entries.cat.request.url + '#mouse')
75 .then(function(result) {
76 assert_array_equivalent(
77 result,
78 [
79 entries.cat.response,
80 ],
81 'Cache.matchAll should ignore URL fragment.');
82 });
83 }, 'Cache.matchAll with URL containing fragment');
84
85 prepopulated_cache_test(simple_entries, function(cache, entries) {
86 return cache.matchAll('http')
87 .then(function(result) {
88 assert_array_equivalent(
89 result, [],
90 'Cache.matchAll should treat query as a URL and not ' +
91 'just a string fragment.');
92 });
93 }, 'Cache.matchAll with string fragment "http" as query');
94
95 prepopulated_cache_test(simple_entries, function(cache, entries) {
96 return cache.matchAll(entries.secret_cat.request.url)
97 .then(function(result) {
98 assert_array_equivalent(
99 result, [entries.secret_cat.response],
100 'Cache.matchAll should not ignore embedded credentials');
101 });
102 }, 'Cache.matchAll with URL containing credentials');
103
104 prepopulated_cache_test(vary_entries, function(cache, entries) {
105 return cache.matchAll('http://example.com/c')
106 .then(function(result) {
107 assert_array_equivalent(
108 result,
109 [
110 entries.vary_wildcard.response,
111 entries.vary_cookie_absent.response
112 ],
113 'Cache.matchAll should exclude matches if a vary header is ' +
114 'missing in the query request, but is present in the cached ' +
115 'request.');
116 })
117
118 .then(function() {
119 return cache.matchAll(
120 new Request('http://example.com/c',
121 {headers: {'Cookies': 'none-of-the-above'}}));
122 })
123 .then(function(result) {
124 assert_array_equivalent(
125 result,
126 [
127 entries.vary_wildcard.response
128 ],
129 'Cache.matchAll should exclude matches if a vary header is ' +
130 'missing in the cached request, but is present in the query ' +
131 'request.');
132 })
133
134 .then(function() {
135 return cache.matchAll(
136 new Request('http://example.com/c',
137 {headers: {'Cookies': 'is-for-cookie'}}));
138 })
139 .then(function(result) {
140 assert_array_equivalent(
141 result,
142 [entries.vary_cookie_is_cookie.response],
143 'Cache.matchAll should match the entire header if a vary header ' +
144 'is present in both the query and cached requests.');
145 });
146 }, 'Cache.matchAll with responses containing "Vary" header');
147
148 prepopulated_cache_test(vary_entries, function(cache, entries) {
149 return cache.matchAll('http://example.com/c',
150 {ignoreVary: true})
151 .then(function(result) {
152 assert_array_equivalent(
153 result,
154 [
155 entries.vary_cookie_is_cookie.response,
156 entries.vary_cookie_is_good.response,
157 entries.vary_cookie_absent.response,
158 entries.vary_wildcard.response
159 ],
160 'Cache.matchAll should honor "ignoreVary" parameter.');
161 });
162 }, 'Cache.matchAll with "ignoreVary" parameter');
163
164 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698