OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // A simple, incomplete implementation of the Cache API, intended to facilitate | 5 // A simple, incomplete implementation of the Cache API, intended to facilitate |
6 // end to end serviceworker testing. | 6 // end to end serviceworker testing. |
7 | 7 |
8 // See https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.htm
l#cache | 8 // See https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.htm
l#cache-objects |
9 | 9 |
10 // FIXME: Support AbstractResponse/OpaqueResponse correctly. | 10 // FIXME: Support AbstractResponse/OpaqueResponse correctly. |
11 // FIXME: Serialize the cache. | 11 // FIXME: Serialize the cache. |
12 // FIXME: Implement CacheStorage API. | |
13 // FIXME: Bind all function references. | 12 // FIXME: Bind all function references. |
14 (function(global) { | 13 (function(global) { |
15 var _castToRequest = function(item) { | 14 var _castToRequest = function(item) { |
16 if (typeof item === 'string') { | 15 if (typeof item === 'string') { |
17 item = new Request({ | 16 item = new Request({ |
18 url: item, | 17 url: item, |
19 }); | 18 }); |
20 } | 19 } |
21 return item; | 20 return item; |
22 }; | 21 }; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 var entry = entriesByUrl[request.url]; | 111 var entry = entriesByUrl[request.url]; |
113 resolve(entry); | 112 resolve(entry); |
114 }); | 113 }); |
115 }; | 114 }; |
116 | 115 |
117 // FIXME: Implement this. | 116 // FIXME: Implement this. |
118 Cache.prototype.matchAll = Promise.reject.bind(Promise, 'Cache.prototype.mat
chAll not implemented.'); | 117 Cache.prototype.matchAll = Promise.reject.bind(Promise, 'Cache.prototype.mat
chAll not implemented.'); |
119 | 118 |
120 global.Cache = global.Cache || Cache; | 119 global.Cache = global.Cache || Cache; |
121 }(self)); // window or worker global scope. | 120 }(self)); // window or worker global scope. |
OLD | NEW |