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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * worker-test-harness should be considered a temporary polyfill around 2 * worker-test-harness should be considered a temporary polyfill around
3 * testharness.js for supporting Service Worker based tests. It should not be 3 * testharness.js for supporting Service Worker based tests. It should not be
4 * necessary once the test harness is able to drive worker based tests natively. 4 * necessary once the test harness is able to drive worker based tests natively.
5 * See https://github.com/w3c/testharness.js/pull/82 for status of effort to 5 * See https://github.com/w3c/testharness.js/pull/82 for status of effort to
6 * update upstream testharness.js. Once the upstreaming is complete, tests that 6 * update upstream testharness.js. Once the upstreaming is complete, tests that
7 * reference worker-test-harness should be updated to directly import 7 * reference worker-test-harness should be updated to directly import
8 * testharness.js. 8 * testharness.js.
9 */ 9 */
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // 'Should throw NotFoundError.'); 95 // 'Should throw NotFoundError.');
96 function assert_promise_throws(promise, code, description) { 96 function assert_promise_throws(promise, code, description) {
97 return promise.then( 97 return promise.then(
98 function() { 98 function() {
99 throw 'assert_promise_throws: ' + description + ' Promise did now throw.'; 99 throw 'assert_promise_throws: ' + description + ' Promise did now throw.';
100 }, 100 },
101 function(e) { 101 function(e) {
102 assert_throws(code, function() { throw e; }, description); 102 assert_throws(code, function() { throw e; }, description);
103 }); 103 });
104 } 104 }
105
106 (function() {
107 var next_cache_index = 1;
108
109 // Returns a promise that resolves to a newly created Cache object. The
110 // returned Cache will be destroyed when |test| completes.
111 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!
112 var uniquifier = base_name || String(++next_cache_index);
113 var cache_name = self.location.pathname + '/' + uniquifier;
114
115 test.add_cleanup(function() {
116 self.caches.delete(cache_name);
117 });
118
119 return self.caches.delete(cache_name)
120 .then(function() {
121 return self.caches.create(cache_name);
122 });
123 }
124
125 self.create_temporary_cache = create_temporary_cache;
126 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698