Skip to content

Commit 5136241

Browse files
inexorabletashCommit bot
authored and
Commit bot
committed
Cache API tests: prepopulate cache in deterministic order
Chrome and Firefox differ in the order in which cache keys() are returned. Chrome orders by according to when the put()s were issued. Firefox orders by when the body is complete. The test helper prepopulated_cache_test did not guarantee that these matched, leading to the tests being flaky in Firefox. This change tweaks the helper so that the put()s are processed serially so that the order is deterministic for both. Spec issue: w3c/ServiceWorker#823 BUG=655479 Review-Url: https://codereview.chromium.org/2806793002 Cr-Commit-Position: refs/heads/master@{#463195}
1 parent 1120947 commit 5136241

File tree

1 file changed

+13
-10
lines changed
  • third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/resources

1 file changed

+13
-10
lines changed

third_party/WebKit/LayoutTests/external/wpt/service-workers/cache-storage/resources/test-helpers.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,26 @@ var vary_entries = [
141141
// Run |test_function| with a Cache object and a map of entries. Prior to the
142142
// call, the Cache is populated by cache entries from |entries|. The latter is
143143
// expected to be an Object mapping arbitrary keys to objects of the form
144-
// {request: <Request object>, response: <Response object>}. There's no
145-
// guarantee on the order in which entries will be added to the cache.
144+
// {request: <Request object>, response: <Response object>}. Entries are
145+
// serially added to the cache in the order specified.
146146
//
147147
// |test_function| should return a Promise that can be used with promise_test.
148148
function prepopulated_cache_test(entries, test_function, description) {
149149
cache_test(function(cache) {
150150
var p = Promise.resolve();
151151
var hash = {};
152-
return Promise.all(entries.map(function(entry) {
152+
entries.forEach(function(entry) {
153153
hash[entry.name] = entry;
154-
return cache.put(entry.request.clone(),
155-
entry.response.clone())
156-
.catch(function(e) {
157-
assert_unreached(
158-
'Test setup failed for entry ' + entry.name + ': ' + e);
159-
});
160-
}))
154+
p = p.then(function() {
155+
return cache.put(entry.request.clone(), entry.response.clone())
156+
.catch(function(e) {
157+
assert_unreached(
158+
'Test setup failed for entry ' + entry.name + ': ' + e
159+
);
160+
});
161+
});
162+
});
163+
return p
161164
.then(function() {
162165
assert_equals(Object.keys(hash).length, entries.length);
163166
})

0 commit comments

Comments
 (0)