| OLD | NEW |
| 1 if (self.importScripts) { | 1 if (self.importScripts) { |
| 2 importScripts('/resources/testharness.js'); | 2 importScripts('/resources/testharness.js'); |
| 3 importScripts('/resources/testharness-helpers.js'); | 3 importScripts('/resources/testharness-helpers.js'); |
| 4 importScripts('../resources/test-helpers.js'); | 4 importScripts('../resources/test-helpers.js'); |
| 5 } | 5 } |
| 6 | 6 |
| 7 (function() { | 7 (function() { |
| 8 var next_index = 1; | 8 var next_index = 1; |
| 9 | 9 |
| 10 // Returns a transaction (request, response, and url) for a unique URL. | 10 // Returns a transaction (request, response, and url) for a unique URL. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 })(); | 23 })(); |
| 24 | 24 |
| 25 cache_test(function(cache) { | 25 cache_test(function(cache) { |
| 26 var transaction = create_unique_transaction(); | 26 var transaction = create_unique_transaction(); |
| 27 | 27 |
| 28 return cache.put(transaction.request.clone(), transaction.response.clone()) | 28 return cache.put(transaction.request.clone(), transaction.response.clone()) |
| 29 .then(function() { | 29 .then(function() { |
| 30 return self.caches.match(transaction.request); | 30 return self.caches.match(transaction.request); |
| 31 }) | 31 }) |
| 32 .then(function(response) { | 32 .then(function(response) { |
| 33 assert_object_equals_fixed(response, transaction.response, | 33 assert_response_equals(response, transaction.response, |
| 34 'The response should not have changed.'); | 34 'The response should not have changed.'); |
| 35 }); | 35 }); |
| 36 }, 'CacheStorageMatch with no cache name provided'); | 36 }, 'CacheStorageMatch with no cache name provided'); |
| 37 | 37 |
| 38 cache_test(function(cache) { | 38 cache_test(function(cache) { |
| 39 var transaction = create_unique_transaction(); | 39 var transaction = create_unique_transaction(); |
| 40 | 40 |
| 41 var test_cache_list = ['a', 'b', 'c']; | 41 var test_cache_list = ['a', 'b', 'c']; |
| 42 return cache.put(transaction.request.clone(), transaction.response.clone()) | 42 return cache.put(transaction.request.clone(), transaction.response.clone()) |
| 43 .then(function() { | 43 .then(function() { |
| 44 return Promise.all(test_cache_list.map(function(key) { | 44 return Promise.all(test_cache_list.map(function(key) { |
| 45 return self.caches.open(key); | 45 return self.caches.open(key); |
| 46 })); | 46 })); |
| 47 }) | 47 }) |
| 48 .then(function() { | 48 .then(function() { |
| 49 return self.caches.match(transaction.request); | 49 return self.caches.match(transaction.request); |
| 50 }) | 50 }) |
| 51 .then(function(response) { | 51 .then(function(response) { |
| 52 assert_object_equals_fixed(response, transaction.response, | 52 assert_response_equals(response, transaction.response, |
| 53 'The response should not have changed.'); | 53 'The response should not have changed.'); |
| 54 }); | 54 }); |
| 55 }, 'CacheStorageMatch from one of many caches'); | 55 }, 'CacheStorageMatch from one of many caches'); |
| 56 | 56 |
| 57 promise_test(function(test) { | 57 promise_test(function(test) { |
| 58 var transaction = create_unique_transaction(); | 58 var transaction = create_unique_transaction(); |
| 59 | 59 |
| 60 var test_cache_list = ['x', 'y', 'z']; | 60 var test_cache_list = ['x', 'y', 'z']; |
| 61 return Promise.all(test_cache_list.map(function(key) { | 61 return Promise.all(test_cache_list.map(function(key) { |
| 62 return self.caches.open(key); | 62 return self.caches.open(key); |
| 63 })) | 63 })) |
| 64 .then(function() { return caches.open('x'); }) | 64 .then(function() { return caches.open('x'); }) |
| 65 .then(function(cache) { | 65 .then(function(cache) { |
| 66 return cache.put(transaction.request.clone(), | 66 return cache.put(transaction.request.clone(), |
| 67 transaction.response.clone()); | 67 transaction.response.clone()); |
| 68 }) | 68 }) |
| 69 .then(function() { | 69 .then(function() { |
| 70 return self.caches.match(transaction.request, {cacheName: 'x'}); | 70 return self.caches.match(transaction.request, {cacheName: 'x'}); |
| 71 }) | 71 }) |
| 72 .then(function(response) { | 72 .then(function(response) { |
| 73 assert_object_equals_fixed(response, transaction.response, | 73 assert_response_equals(response, transaction.response, |
| 74 'The response should not have changed.'); | 74 'The response should not have changed.'); |
| 75 }) | 75 }) |
| 76 .then(function() { | 76 .then(function() { |
| 77 return self.caches.match(transaction.request, {cacheName: 'y'}); | 77 return self.caches.match(transaction.request, {cacheName: 'y'}); |
| 78 }) | 78 }) |
| 79 .then(function(response) { | 79 .then(function(response) { |
| 80 assert_equals(response, undefined, | 80 assert_equals(response, undefined, |
| 81 'Cache y should not have a response for the request.'); | 81 'Cache y should not have a response for the request.'); |
| 82 }); | 82 }); |
| 83 }, 'CacheStorageMatch from one of many caches by name'); | 83 }, 'CacheStorageMatch from one of many caches by name'); |
| 84 | 84 |
| 85 cache_test(function(cache) { | 85 cache_test(function(cache) { |
| 86 var transaction = create_unique_transaction(); | 86 var transaction = create_unique_transaction(); |
| 87 return cache.put(transaction.url, transaction.response.clone()) | 87 return cache.put(transaction.url, transaction.response.clone()) |
| 88 .then(function() { | 88 .then(function() { |
| 89 return self.caches.match(transaction.request); | 89 return self.caches.match(transaction.request); |
| 90 }) | 90 }) |
| 91 .then(function(response) { | 91 .then(function(response) { |
| 92 assert_object_equals_fixed(response, transaction.response, | 92 assert_response_equals(response, transaction.response, |
| 93 'The response should not have changed.'); | 93 'The response should not have changed.'); |
| 94 }); | 94 }); |
| 95 }, 'CacheStorageMatch a string request'); | 95 }, 'CacheStorageMatch a string request'); |
| 96 | 96 |
| 97 promise_test(function(test) { | 97 promise_test(function(test) { |
| 98 var transaction = create_unique_transaction(); | 98 var transaction = create_unique_transaction(); |
| 99 return self.caches.match(transaction.request) | 99 return self.caches.match(transaction.request) |
| 100 .then(function(response) { | 100 .then(function(response) { |
| 101 assert_equals(response, undefined, | 101 assert_equals(response, undefined, |
| 102 'The response should not be found.'); | 102 'The response should not be found.'); |
| 103 }) | 103 }) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 114 assert_equals(response, undefined, | 114 assert_equals(response, undefined, |
| 115 'The response should not be found.'); | 115 'The response should not be found.'); |
| 116 return self.caches.has('foo'); | 116 return self.caches.has('foo'); |
| 117 }) | 117 }) |
| 118 .then(function(has_foo) { | 118 .then(function(has_foo) { |
| 119 assert_false(has_foo, "The cache should still not exist."); | 119 assert_false(has_foo, "The cache should still not exist."); |
| 120 }) | 120 }) |
| 121 }, 'CacheStorageMatch with no caches available but name provided'); | 121 }, 'CacheStorageMatch with no caches available but name provided'); |
| 122 | 122 |
| 123 done(); | 123 done(); |
| OLD | NEW |