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

Unified Diff: LayoutTests/http/tests/serviceworker/resources/worker-test-harness.js

Issue 425413002: [ServiceWorker] Tests for Cache (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments. Created 6 years, 4 months 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 side-by-side diff with in-line comments
Download patch
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 3d45c2270cce1988908fb58366f3f7d07a2635aa..646e08d9eae93f4a7874e1397046d42fbe4535b9 100644
--- a/LayoutTests/http/tests/serviceworker/resources/worker-test-harness.js
+++ b/LayoutTests/http/tests/serviceworker/resources/worker-test-harness.js
@@ -102,3 +102,25 @@ function assert_promise_throws(promise, code, description) {
assert_throws(code, function() { throw e; }, 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) {
jsbell 2014/08/20 18:18:08 This is great!
asanka 2014/08/20 21:24:58 Thanks!
+ 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;
+})();

Powered by Google App Engine
This is Rietveld 408576698