Index: Source/modules/serviceworkers/polyfills/cachePolyfill.js |
diff --git a/Source/modules/serviceworkers/polyfills/cachePolyfill.js b/Source/modules/serviceworkers/polyfills/cachePolyfill.js |
index 1c90a0348942248916cf88abffda633f8c9cad1a..381867e9ab95130eab1c0d19616b88b44bd57955 100644 |
--- a/Source/modules/serviceworkers/polyfills/cachePolyfill.js |
+++ b/Source/modules/serviceworkers/polyfills/cachePolyfill.js |
@@ -60,8 +60,17 @@ |
}); |
}; |
- // FIXME: Implement this. |
- Cache.prototype.add = Promise.reject.bind(Promise, 'Cache.prototype.add() not implemented.'); |
+ Cache.prototype.add = function(request) { |
+ var that = this; |
+ request = _castToRequest(request); |
+ return new Promise(function (resolve, reject) { |
+ fetch(request).then( |
+ function(response) { |
+ that.put(request, response).then(resolve); |
+ }, |
+ reject); |
+ }); |
+ }; |
// FIXME: Add QueryParams argument. |
Cache.prototype.delete = function (request) { |