OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script> | 2 <script> |
3 function fetch_url(url) { | 3 function fetch_url(url) { |
4 return new Promise(function(resolve, reject) { | 4 return new Promise(function(resolve, reject) { |
5 var request = new XMLHttpRequest(); | 5 var request = new XMLHttpRequest(); |
6 request.addEventListener('load', function(event) { | 6 request.addEventListener('load', function(event) { |
7 resolve(); | 7 resolve(); |
8 }); | 8 }); |
9 request.addEventListener('error', function(event) { | 9 request.addEventListener('error', function(event) { |
10 reject(); | 10 reject(); |
(...skipping 16 matching lines...) Expand all Loading... | |
27 function() { | 27 function() { |
28 if (!testcase.expect_load) | 28 if (!testcase.expect_load) |
29 return Promise.resolve(); | 29 return Promise.resolve(); |
30 return Promise.reject(new Error( | 30 return Promise.reject(new Error( |
31 name + ': expected to load but got network error')); | 31 name + ': expected to load but got network error')); |
32 }); | 32 }); |
33 } | 33 } |
34 | 34 |
35 function run_tests() { | 35 function run_tests() { |
36 var tests = [ | 36 var tests = [ |
37 { name: 'prevent-default-and-respond-with', expect_load: true }, | 37 { name: 'response-object', expect_load: true }, |
38 { name: 'prevent-default', expect_load: false }, | 38 { name: 'response-promise-object', expect_load: true }, |
39 { name: 'reject', expect_load: false }, | 39 { name: 'other-value', expect_load: false }, |
falken
2015/07/27 00:44:41
'object' or 'object-instance' seems more clear tha
jungkees
2015/07/27 01:21:32
IMO, any single case which is neither a Response n
| |
40 { name: 'unused-body', expect_load: true }, | |
41 { name: 'used-body', expect_load: false }, | |
42 { name: 'unused-fetched-body', expect_load: true }, | |
43 { name: 'used-fetched-body', expect_load: false } | |
44 ].map(make_test); | 40 ].map(make_test); |
45 | 41 |
46 Promise.all(tests) | 42 Promise.all(tests) |
47 .then(function() { | 43 .then(function() { |
48 window.parent.notify_test_done('PASS'); | 44 window.parent.notify_test_done('PASS'); |
49 }) | 45 }) |
50 .catch(function(error) { | 46 .catch(function(error) { |
51 window.parent.notify_test_done('FAIL: ' + error.message); | 47 window.parent.notify_test_done('FAIL: ' + error.message); |
52 }); | 48 }); |
53 } | 49 } |
54 | 50 |
55 if (!navigator.serviceWorker.controller) | 51 if (!navigator.serviceWorker.controller) |
56 window.parent.notify_done('FAIL: no controller'); | 52 window.parent.notify_done('FAIL: no controller'); |
57 else | 53 else |
58 run_tests(); | 54 run_tests(); |
59 </script> | 55 </script> |
OLD | NEW |