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

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

Issue 425413002: [ServiceWorker] Tests for Cache (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: CacheStorage.{create => open} Created 6 years, 2 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-testharness.js
diff --git a/LayoutTests/http/tests/serviceworker/resources/worker-testharness.js b/LayoutTests/http/tests/serviceworker/resources/worker-testharness.js
index 986c86a82ed7d8960380e258e78f03d5ccdd8bf8..b58552acfad10d8e4b885125a3dc17b6b0c8eec3 100644
--- a/LayoutTests/http/tests/serviceworker/resources/worker-testharness.js
+++ b/LayoutTests/http/tests/serviceworker/resources/worker-testharness.js
@@ -72,3 +72,25 @@ importScripts('/resources/testharness.js');
}
});
})();
+
+(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/10/20 18:20:41 Is it worth having the `base_name` param now, sinc
asanka 2014/10/22 22:35:32 Removed.
+ 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.open(cache_name);
+ });
+ }
+
+ self.create_temporary_cache = create_temporary_cache;
+})();

Powered by Google App Engine
This is Rietveld 408576698