Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 importScripts('worker-testharness.js'); | 1 importScripts('worker-testharness.js'); |
| 2 importScripts('test-helpers.js'); | 2 importScripts('test-helpers.js'); |
| 3 | 3 |
| 4 async_test(function(t) { | 4 async_test(function(t) { |
| 5 fetch('http://') | 5 fetch('http://') |
| 6 .then( | 6 .then( |
| 7 unreached_rejection(t, 'fetch of invalid URL must fail'), | 7 unreached_rejection(t, 'fetch of invalid URL must fail'), |
| 8 function(e) { | 8 function(e) { |
| 9 assert_equals(e.message, 'Invalid URL'); | 9 assert_equals(e.message, 'Invalid URL'); |
| 10 t.done(); | 10 t.done(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 assert_equals(files['BlobKey'].name, 'blob'); | 132 assert_equals(files['BlobKey'].name, 'blob'); |
| 133 assert_equals(files['BlobKey'].size, 12); | 133 assert_equals(files['BlobKey'].size, 12); |
| 134 assert_equals(files['FileKey'].content, 'file content'); | 134 assert_equals(files['FileKey'].content, 'file content'); |
| 135 assert_equals(files['FileKey'].name, 'file.dat'); | 135 assert_equals(files['FileKey'].name, 'file.dat'); |
| 136 assert_equals(files['FileKey'].size, 12); | 136 assert_equals(files['FileKey'].size, 12); |
| 137 t.done(); | 137 t.done(); |
| 138 }) | 138 }) |
| 139 .catch(unreached_rejection(t)); | 139 .catch(unreached_rejection(t)); |
| 140 }, 'Fetch with FormData body test in ServiceWorkerGlobalScope'); | 140 }, 'Fetch with FormData body test in ServiceWorkerGlobalScope'); |
| 141 | 141 |
| 142 async_test(function(t) { | |
| 143 var url = get_host_info()['HTTP_REMOTE_ORIGIN'] + '/dymmy.html'; | |
|
falken
2014/11/17 02:14:46
nit: dummy
horo
2014/11/17 03:25:35
Done.
| |
| 144 fetch(new Request(url, {mode: 'same-origin'})) | |
| 145 .then( | |
| 146 unreached_rejection(t, 'Fetching must fail.'), | |
| 147 function(e) { | |
| 148 assert_equals( | |
| 149 e.message, | |
| 150 'Fetch API cannot load ' + url + '. ' + | |
| 151 'Request mode is "same-origin" but the URL is not same origin.'); | |
| 152 t.done(); | |
| 153 }) | |
| 154 .catch(unreached_rejection(t)); | |
| 155 }, 'Fetch API error message - not same origin request'); | |
| 156 | |
| 157 async_test(function(t) { | |
| 158 var url = 'ftp://example.com/dummy.html'; | |
| 159 fetch(new Request(url, {mode: 'cors'})) | |
| 160 .then( | |
| 161 unreached_rejection(t, 'Fetching must fail.'), | |
| 162 function(e) { | |
| 163 assert_equals( | |
| 164 e.message, | |
| 165 'Fetch API cannot load ' + url + '. ' + | |
| 166 'URL scheme must be "http" or "https" for CORS request.'); | |
| 167 t.done(); | |
| 168 }) | |
| 169 .catch(unreached_rejection(t)); | |
| 170 }, 'Fetch API error message - non http cors request'); | |
| 171 | |
| 172 async_test(function(t) { | |
| 173 var url = 'about://blank'; | |
| 174 fetch(new Request(url)) | |
| 175 .then( | |
| 176 unreached_rejection(t, 'Fetching must fail.'), | |
| 177 function(e) { | |
| 178 assert_equals( | |
| 179 e.message, | |
| 180 'Fetch API cannot load ' + url + '. ' + | |
| 181 'URL scheme "about" is not supported.'); | |
| 182 t.done(); | |
| 183 }) | |
| 184 .catch(unreached_rejection(t)); | |
| 185 }, 'Fetch API error message - unsupported scheme.'); | |
| 186 | |
| 187 async_test(function(t) { | |
| 188 var url = get_host_info()['HTTP_ORIGIN'] + base_path() + | |
| 189 'invalid-chunked-encoding.php'; | |
| 190 fetch(new Request(url)) | |
| 191 .then( | |
| 192 unreached_rejection(t, 'Fetching must fail.'), | |
| 193 function(e) { | |
| 194 assert_equals( | |
| 195 e.message, | |
| 196 'Fetch API cannot load ' + url + '. ' + | |
| 197 'net::ERR_INVALID_CHUNKED_ENCODING'); | |
| 198 t.done(); | |
| 199 }) | |
| 200 .catch(unreached_rejection(t)); | |
| 201 }, 'Fetch API error message - invalid chunled encoding.'); | |
|
falken
2014/11/17 02:14:46
nit: chunked
horo
2014/11/17 03:25:35
Done.
| |
| 202 | |
| 203 async_test(function(t) { | |
| 204 var url = get_host_info()['HTTP_REMOTE_ORIGIN'] + base_path() + | |
| 205 'fetch-access-control.php'; | |
| 206 fetch(new Request(url)) | |
| 207 .then( | |
| 208 unreached_rejection(t, 'Fetching must fail.'), | |
| 209 function(e) { | |
| 210 assert_equals( | |
| 211 e.message, | |
| 212 'Fetch API cannot load ' + url + '. ' + | |
| 213 'No \'Access-Control-Allow-Origin\' header is present on the ' + | |
| 214 'requested resource. Origin \'' + get_host_info()['HTTP_ORIGIN'] + | |
| 215 '\' is therefore not allowed access.'); | |
| 216 t.done(); | |
| 217 }) | |
| 218 .catch(unreached_rejection(t)); | |
| 219 }, 'Fetch API error message - cors error.'); | |
| 220 | |
| 221 async_test(function(t) { | |
| 222 // FIXME: When we support the redirection in Fech API, we have to change | |
| 223 // this test case. | |
| 224 var url = get_host_info()['HTTP_ORIGIN'] + base_path() + | |
| 225 'redirect.php?Redirect=http://www.example.com'; | |
| 226 fetch(new Request(url)) | |
| 227 .then( | |
| 228 unreached_rejection(t, 'Fetching must fail.'), | |
| 229 function(e) { | |
| 230 assert_equals( | |
| 231 e.message, | |
| 232 'Fetch API cannot load ' + url + '. ' + | |
| 233 'Unsupported redirection.'); | |
| 234 t.done(); | |
| 235 }) | |
| 236 .catch(unreached_rejection(t)); | |
| 237 }, 'Fetch API error message - redirect error.'); | |
| 238 | |
| 142 test(function(t) { | 239 test(function(t) { |
| 143 function runInfiniteFetchLoop() { | 240 function runInfiniteFetchLoop() { |
| 144 fetch('dummy.html') | 241 fetch('dummy.html') |
| 145 .then(function() { runInfiniteFetchLoop(); }); | 242 .then(function() { runInfiniteFetchLoop(); }); |
| 146 } | 243 } |
| 147 runInfiniteFetchLoop(); | 244 runInfiniteFetchLoop(); |
| 148 }, | 245 }, |
| 149 'Destroying the execution context while fetch is happening should not ' + | 246 'Destroying the execution context while fetch is happening should not ' + |
| 150 'cause a crash.'); | 247 'cause a crash.'); |
| OLD | NEW |