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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/cache-storage/script-tests/cache-storage-match.js

Issue 2547023002: Import wpt@3c8896ae408c8fd594979da7c99970029e7856a7 (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. Created 4 years 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
OLDNEW
1 if (self.importScripts) { 1 if (self.importScripts) {
2 importScripts('/resources/testharness.js'); 2 importScripts('/resources/testharness.js');
3 importScripts('../resources/testharness-helpers.js');
4 importScripts('../resources/test-helpers.js'); 3 importScripts('../resources/test-helpers.js');
5 } 4 }
6 5
7 (function() { 6 (function() {
8 var next_index = 1; 7 var next_index = 1;
9 8
10 // Returns a transaction (request, response, and url) for a unique URL. 9 // Returns a transaction (request, response, and url) for a unique URL.
11 function create_unique_transaction(test) { 10 function create_unique_transaction(test) {
12 var uniquifier = String(next_index++); 11 var uniquifier = String(next_index++);
13 var url = 'http://example.com/' + uniquifier; 12 var url = 'http://example.com/' + uniquifier;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 }); 53 });
55 }, 'CacheStorageMatch from one of many caches'); 54 }, 'CacheStorageMatch from one of many caches');
56 55
57 promise_test(function(test) { 56 promise_test(function(test) {
58 var transaction = create_unique_transaction(); 57 var transaction = create_unique_transaction();
59 58
60 var test_cache_list = ['x', 'y', 'z']; 59 var test_cache_list = ['x', 'y', 'z'];
61 return Promise.all(test_cache_list.map(function(key) { 60 return Promise.all(test_cache_list.map(function(key) {
62 return self.caches.open(key); 61 return self.caches.open(key);
63 })) 62 }))
64 .then(function() { return caches.open('x'); }) 63 .then(function() { return self.caches.open('x'); })
65 .then(function(cache) { 64 .then(function(cache) {
66 return cache.put(transaction.request.clone(), 65 return cache.put(transaction.request.clone(),
67 transaction.response.clone()); 66 transaction.response.clone());
68 }) 67 })
69 .then(function() { 68 .then(function() {
70 return self.caches.match(transaction.request, {cacheName: 'x'}); 69 return self.caches.match(transaction.request, {cacheName: 'x'});
71 }) 70 })
72 .then(function(response) { 71 .then(function(response) {
73 assert_response_equals(response, transaction.response, 72 assert_response_equals(response, transaction.response,
74 'The response should not have changed.'); 73 'The response should not have changed.');
(...skipping 18 matching lines...) Expand all
93 'The response should not have changed.'); 92 'The response should not have changed.');
94 }); 93 });
95 }, 'CacheStorageMatch a string request'); 94 }, 'CacheStorageMatch a string request');
96 95
97 promise_test(function(test) { 96 promise_test(function(test) {
98 var transaction = create_unique_transaction(); 97 var transaction = create_unique_transaction();
99 return self.caches.match(transaction.request) 98 return self.caches.match(transaction.request)
100 .then(function(response) { 99 .then(function(response) {
101 assert_equals(response, undefined, 100 assert_equals(response, undefined,
102 'The response should not be found.'); 101 'The response should not be found.');
103 }) 102 });
104 }, 'CacheStorageMatch with no cached entry'); 103 }, 'CacheStorageMatch with no cached entry');
105 104
106 promise_test(function(test) { 105 promise_test(function(test) {
107 var transaction = create_unique_transaction(); 106 var transaction = create_unique_transaction();
108 return self.caches.has('foo') 107 return self.caches.has('foo')
109 .then(function(has_foo) { 108 .then(function(has_foo) {
110 assert_false(has_foo, "The cache should not exist."); 109 assert_false(has_foo, "The cache should not exist.");
111 return self.caches.match(transaction.request, {cacheName: 'foo'}); 110 return self.caches.match(transaction.request, {cacheName: 'foo'});
112 }) 111 })
113 .then(function(response) { 112 .then(function(response) {
114 assert_equals(response, undefined, 113 assert_equals(response, undefined,
115 'The match with bad cache name should resolve to ' + 114 'The match with bad cache name should resolve to ' +
116 'undefined.'); 115 'undefined.');
117 return self.caches.has('foo'); 116 return self.caches.has('foo');
118 }) 117 })
119 .then(function(has_foo) { 118 .then(function(has_foo) {
120 assert_false(has_foo, "The cache should still not exist."); 119 assert_false(has_foo, "The cache should still not exist.");
121 }) 120 })
122 }, 'CacheStorageMatch with no caches available but name provided'); 121 }, 'CacheStorageMatch with no caches available but name provided');
123 122
124 done(); 123 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698