OLD | NEW |
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return promise.then( | 103 return promise.then( |
104 function() { | 104 function() { |
105 throw 'assert_promise_rejects: ' + description + ' Promise did not throw.'
; | 105 throw 'assert_promise_rejects: ' + description + ' Promise did not throw.'
; |
106 }, | 106 }, |
107 function(e) { | 107 function(e) { |
108 if (code !== undefined) { | 108 if (code !== undefined) { |
109 assert_throws(code, function() { throw e; }, description); | 109 assert_throws(code, function() { throw e; }, description); |
110 } | 110 } |
111 }); | 111 }); |
112 } | 112 } |
| 113 |
| 114 (function() { |
| 115 var next_cache_index = 1; |
| 116 |
| 117 // Returns a promise that resolves to a newly created Cache object. The |
| 118 // returned Cache will be destroyed when |test| completes. |
| 119 function create_temporary_cache(test, base_name) { |
| 120 var uniquifier = base_name || String(++next_cache_index); |
| 121 var cache_name = self.location.pathname + '/' + uniquifier; |
| 122 |
| 123 test.add_cleanup(function() { |
| 124 self.caches.delete(cache_name); |
| 125 }); |
| 126 |
| 127 return self.caches.delete(cache_name) |
| 128 .then(function() { |
| 129 return self.caches.create(cache_name); |
| 130 }); |
| 131 } |
| 132 |
| 133 self.create_temporary_cache = create_temporary_cache; |
| 134 })(); |
OLD | NEW |