OLD | NEW |
1 if (self.importScripts) { | 1 if (self.importScripts) { |
2 importScripts('/resources/testharness.js'); | 2 importScripts('/resources/testharness.js'); |
3 importScripts('../resources/test-helpers.js'); | 3 importScripts('../resources/test-helpers.js'); |
4 } | 4 } |
5 | 5 |
6 cache_test(function(cache, test) { | 6 cache_test(function(cache, test) { |
7 return promise_rejects( | 7 return promise_rejects( |
8 test, | 8 test, |
9 new TypeError(), | 9 new TypeError(), |
10 cache.add(), | 10 cache.add(), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return request.text() | 77 return request.text() |
78 .then(function() { | 78 .then(function() { |
79 assert_false(request.bodyUsed); | 79 assert_false(request.bodyUsed); |
80 }) | 80 }) |
81 .then(function() { | 81 .then(function() { |
82 return cache.add(request); | 82 return cache.add(request); |
83 }); | 83 }); |
84 }, 'Cache.add with request with null body (not consumed)'); | 84 }, 'Cache.add with request with null body (not consumed)'); |
85 | 85 |
86 cache_test(function(cache, test) { | 86 cache_test(function(cache, test) { |
87 return assert_promise_rejects( | 87 return promise_rejects( |
88 test, | 88 test, |
89 new TypeError(), | 89 new TypeError(), |
90 cache.add('../resources/fetch-status.py?status=206'), | 90 cache.add('../resources/fetch-status.py?status=206'), |
91 'Cache.add should reject on partial response'); | 91 'Cache.add should reject on partial response'); |
92 }, 'Cache.add with 206 response'); | 92 }, 'Cache.add with 206 response'); |
93 | 93 |
94 cache_test(function(cache, test) { | 94 cache_test(function(cache, test) { |
95 var urls = ['../resources/fetch-status.py?status=206', | 95 var urls = ['../resources/fetch-status.py?status=206', |
96 '../resources/fetch-status.py?status=200']; | 96 '../resources/fetch-status.py?status=200']; |
97 var requests = urls.map(function(url) { | 97 var requests = urls.map(function(url) { |
98 return new Request(url); | 98 return new Request(url); |
99 }); | 99 }); |
100 return promise_rejects( | 100 return promise_rejects( |
| 101 test, |
101 new TypeError(), | 102 new TypeError(), |
102 cache.addAll(requests), | 103 cache.addAll(requests), |
103 'Cache.addAll should reject with TypeError if any request fails'); | 104 'Cache.addAll should reject with TypeError if any request fails'); |
104 }, 'Cache.addAll with 206 response'); | 105 }, 'Cache.addAll with 206 response'); |
105 | 106 |
106 cache_test(function(cache, test) { | 107 cache_test(function(cache, test) { |
107 return promise_rejects( | 108 return promise_rejects( |
108 test, | 109 test, |
109 new TypeError(), | 110 new TypeError(), |
110 cache.add('this-does-not-exist-please-dont-create-it'), | 111 cache.add('this-does-not-exist-please-dont-create-it'), |
111 'Cache.add should reject if response is !ok'); | 112 'Cache.add should reject if response is !ok'); |
112 }, 'Cache.add with request that results in a status of 404'); | 113 }, 'Cache.add with request that results in a status of 404'); |
113 | 114 |
114 | 115 |
115 cache_test(function(cache, test) { | 116 cache_test(function(cache, test) { |
116 return promise_rejects( | 117 return promise_rejects( |
117 test, | 118 test, |
118 new TypeError(), | 119 new TypeError(), |
119 cache.add('../resources/fetch-status.php?status=500'), | 120 cache.add('../resources/fetch-status.py?status=500'), |
120 'Cache.add should reject if response is !ok'); | 121 'Cache.add should reject if response is !ok'); |
121 }, 'Cache.add with request that results in a status of 500'); | 122 }, 'Cache.add with request that results in a status of 500'); |
122 | 123 |
123 cache_test(function(cache, test) { | 124 cache_test(function(cache, test) { |
124 return promise_rejects( | 125 return promise_rejects( |
125 test, | 126 test, |
126 new TypeError(), | 127 new TypeError(), |
127 cache.addAll(), | 128 cache.addAll(), |
128 'Cache.addAll with no arguments should throw TypeError.'); | 129 'Cache.addAll with no arguments should throw TypeError.'); |
129 }, 'Cache.addAll with no arguments'); | 130 }, 'Cache.addAll with no arguments'); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 var request = new Request('../resources/simple.txt'); | 261 var request = new Request('../resources/simple.txt'); |
261 return promise_rejects( | 262 return promise_rejects( |
262 test, | 263 test, |
263 'InvalidStateError', | 264 'InvalidStateError', |
264 cache.addAll([request, request]), | 265 cache.addAll([request, request]), |
265 'Cache.addAll should throw InvalidStateError if the same request is added
' + | 266 'Cache.addAll should throw InvalidStateError if the same request is added
' + |
266 'twice.'); | 267 'twice.'); |
267 }, 'Cache.addAll called with the same Request object specified twice'); | 268 }, 'Cache.addAll called with the same Request object specified twice'); |
268 | 269 |
269 done(); | 270 done(); |
OLD | NEW |