Index: LayoutTests/http/tests/serviceworker/resources/worker-test-harness.js |
diff --git a/LayoutTests/http/tests/serviceworker/resources/worker-test-harness.js b/LayoutTests/http/tests/serviceworker/resources/worker-test-harness.js |
index 4129f8f8178f4f42f0aa135c383b31962ea1c99b..0407abde08fc7948a92beb6998acbb6615e7a090 100644 |
--- a/LayoutTests/http/tests/serviceworker/resources/worker-test-harness.js |
+++ b/LayoutTests/http/tests/serviceworker/resources/worker-test-harness.js |
@@ -110,3 +110,25 @@ function assert_promise_rejects(promise, code, description) { |
} |
}); |
} |
+ |
+(function() { |
+ var next_cache_index = 1; |
+ |
+ // Returns a promise that resolves to a newly created Cache object. The |
+ // returned Cache will be destroyed when |test| completes. |
+ function create_temporary_cache(test, base_name) { |
+ var uniquifier = base_name || String(++next_cache_index); |
+ var cache_name = self.location.pathname + '/' + uniquifier; |
+ |
+ test.add_cleanup(function() { |
+ self.caches.delete(cache_name); |
+ }); |
+ |
+ return self.caches.delete(cache_name) |
+ .then(function() { |
+ return self.caches.create(cache_name); |
+ }); |
+ } |
+ |
+ self.create_temporary_cache = create_temporary_cache; |
+})(); |