| OLD | NEW |
| 1 importScripts('worker-testharness.js'); | 1 importScripts('worker-testharness.js'); |
| 2 importScripts('/resources/testharness-helpers.js'); | 2 importScripts('/resources/testharness-helpers.js'); |
| 3 | 3 |
| 4 cache_test(function(cache) { | 4 cache_test(function(cache) { |
| 5 return assert_promise_rejects( | 5 return assert_promise_rejects( |
| 6 cache.add(), | 6 cache.add(), |
| 7 new TypeError(), | 7 new TypeError(), |
| 8 'Cache.add should throw a TypeError when no arguments are given.'); | 8 'Cache.add should throw a TypeError when no arguments are given.'); |
| 9 }, 'Cache.add called with no arguments'); | 9 }, 'Cache.add called with no arguments'); |
| 10 | 10 |
| 11 cache_test(function(cache) { | 11 cache_test(function(cache) { |
| 12 return cache.add('simple.txt') | 12 return cache.add('simple.txt') |
| 13 .then(function(result) { | 13 .then(function(result) { |
| 14 assert_equals(result, undefined, | 14 assert_equals(result, undefined, |
| 15 'Cache.add should resolve with undefined on success.'); | 15 'Cache.add should resolve with undefined on success.'); |
| 16 }); | 16 }); |
| 17 }, 'Cache.add called with relative URL specified as a string'); | 17 }, 'Cache.add called with relative URL specified as a string'); |
| 18 | 18 |
| 19 cache_test(function(cache) { | 19 cache_test(function(cache) { |
| 20 return assert_promise_rejects( | 20 return assert_promise_rejects( |
| 21 cache.add('javascript://this-is-not-http-mmkay'), | 21 cache.add('javascript://this-is-not-http-mmkay'), |
| 22 'NetworkError', | 22 'NetworkError', |
| 23 'Cache.add should throw a NetworkError for non-HTTP/HTTPS URLs.'); | 23 'Cache.add should throw a NetworkError for non-HTTP/HTTPS URLs.'); |
| 24 }, 'Cache.add called with non-HTTP/HTTPS URL'); | 24 }, 'Cache.add called with non-HTTP/HTTPS URL'); |
| 25 | 25 |
| 26 cache_test(function(cache) { | 26 cache_test(function(cache) { |
| 27 var request = new Request('simple.txt', {body: 'Hello'}); | 27 var request = new Request('simple.txt', {method: 'POST', body: 'Hello'}); |
| 28 return cache.add(request) | 28 return cache.add(request) |
| 29 .then(function(result) { | 29 .then(function(result) { |
| 30 assert_equals(result, undefined, | 30 assert_equals(result, undefined, |
| 31 'Cache.add should resolve with undefined on success.'); | 31 'Cache.add should resolve with undefined on success.'); |
| 32 }); | 32 }); |
| 33 }, 'Cache.add called with Request object'); | 33 }, 'Cache.add called with Request object'); |
| 34 | 34 |
| 35 cache_test(function(cache) { | 35 cache_test(function(cache) { |
| 36 var request = new Request('simple.txt', {body: 'Hello'}); | 36 var request = new Request('simple.txt', {method: 'POST', body: 'Hello'}); |
| 37 return request.text() | 37 return request.text() |
| 38 .then(function() { | 38 .then(function() { |
| 39 assert_true(request.bodyUsed); | 39 assert_true(request.bodyUsed); |
| 40 }) | 40 }) |
| 41 .then(function() { | 41 .then(function() { |
| 42 return assert_promise_rejects( | 42 return assert_promise_rejects( |
| 43 cache.add(request), | 43 cache.add(request), |
| 44 new TypeError(), | 44 new TypeError(), |
| 45 'Cache.add with a Request object with a used body should reject ' + | 45 'Cache.add with a Request object with a used body should reject ' + |
| 46 'with a TypeError.'); | 46 'with a TypeError.'); |
| 47 }); | 47 }); |
| 48 }, 'Cache.add called with Request object with a used body'); | 48 }, 'Cache.add called with Request object with a used body'); |
| 49 | 49 |
| 50 cache_test(function(cache) { | 50 cache_test(function(cache) { |
| 51 var request = new Request('simple.txt', {body: 'Hello'}); | 51 var request = new Request('simple.txt', {method: 'POST', body: 'Hello'}); |
| 52 return cache.add(request) | 52 return cache.add(request) |
| 53 .then(function(result) { | 53 .then(function(result) { |
| 54 assert_equals(result, undefined, | 54 assert_equals(result, undefined, |
| 55 'Cache.add should resolve with undefined on success.'); | 55 'Cache.add should resolve with undefined on success.'); |
| 56 }) | 56 }) |
| 57 .then(function() { | 57 .then(function() { |
| 58 return assert_promise_rejects( | 58 return assert_promise_rejects( |
| 59 cache.add(request), | 59 cache.add(request), |
| 60 new TypeError(), | 60 new TypeError(), |
| 61 'Cache.add should throw TypeError if same request is added twice.'); | 61 'Cache.add should throw TypeError if same request is added twice.'); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 }, 'Cache.addAll with a mix of succeeding and failing requests'); | 138 }, 'Cache.addAll with a mix of succeeding and failing requests'); |
| 139 | 139 |
| 140 cache_test(function(cache) { | 140 cache_test(function(cache) { |
| 141 var request = new Request('simple.txt'); | 141 var request = new Request('simple.txt'); |
| 142 return assert_promise_rejects( | 142 return assert_promise_rejects( |
| 143 cache.addAll([request, request]), | 143 cache.addAll([request, request]), |
| 144 new TypeError(), | 144 new TypeError(), |
| 145 'Cache.addAll should throw TypeError if the same request is added ' + | 145 'Cache.addAll should throw TypeError if the same request is added ' + |
| 146 'twice.'); | 146 'twice.'); |
| 147 }, 'Cache.addAll called with the same Request object specified twice'); | 147 }, 'Cache.addAll called with the same Request object specified twice'); |
| OLD | NEW |