| OLD | NEW |
| 1 /* | |
| 2 * worker-test-harness should be considered a temporary polyfill around | |
| 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. | |
| 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 | |
| 7 * reference worker-test-harness should be updated to directly import | |
| 8 * testharness.js. | |
| 9 */ | |
| 10 | |
| 11 importScripts('/resources/testharness.js'); | |
| 12 | |
| 13 (function() { | 1 (function() { |
| 14 var next_cache_index = 1; | 2 var next_cache_index = 1; |
| 15 | 3 |
| 16 // Returns a promise that resolves to a newly created Cache object. The | 4 // Returns a promise that resolves to a newly created Cache object. The |
| 17 // returned Cache will be destroyed when |test| completes. | 5 // returned Cache will be destroyed when |test| completes. |
| 18 function create_temporary_cache(test) { | 6 function create_temporary_cache(test) { |
| 19 var uniquifier = String(++next_cache_index); | 7 var uniquifier = String(++next_cache_index); |
| 20 var cache_name = self.location.pathname + '/' + uniquifier; | 8 var cache_name = self.location.pathname + '/' + uniquifier; |
| 21 | 9 |
| 22 test.add_cleanup(function() { | 10 test.add_cleanup(function() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 40 // E.g.: | 28 // E.g.: |
| 41 // cache_test(function(cache) { | 29 // cache_test(function(cache) { |
| 42 // // Do something with |cache|, which is a Cache object. | 30 // // Do something with |cache|, which is a Cache object. |
| 43 // }, "Some Cache test"); | 31 // }, "Some Cache test"); |
| 44 function cache_test(test_function, description) { | 32 function cache_test(test_function, description) { |
| 45 promise_test(function(test) { | 33 promise_test(function(test) { |
| 46 return create_temporary_cache(test) | 34 return create_temporary_cache(test) |
| 47 .then(test_function); | 35 .then(test_function); |
| 48 }, description); | 36 }, description); |
| 49 } | 37 } |
| OLD | NEW |