| OLD | NEW |
| 1 self.onmessage = function(e) { | 1 self.onmessage = function(e) { |
| 2 var message = e.data; | 2 var message = e.data; |
| 3 if ('port' in message) { | 3 if ('port' in message) { |
| 4 port = message.port; | 4 port = message.port; |
| 5 doNextFetchTest(port); | 5 doNextFetchTest(port); |
| 6 } | 6 } |
| 7 }; | 7 }; |
| 8 | 8 |
| 9 var testTargets = [ | 9 var testTargets = [ |
| 10 'other.html', | 10 'other.html', |
| 11 'http://', | 11 'http://', |
| 12 'http://www.example.com/foo', | 12 'http://www.example.com/foo', |
| 13 'fetch-status.php?status=200', | 13 'fetch-status.php?status=200', |
| 14 'fetch-status.php?status=404' | 14 'fetch-status.php?status=404' |
| 15 ]; | 15 ]; |
| 16 | 16 |
| 17 function doNextFetchTest(port) { | 17 function doNextFetchTest(port) { |
| 18 | |
| 19 function runInfiniteFetchLoop() { | |
| 20 fetch('dummy.html') | |
| 21 .then(function() { runInfiniteFetchLoop(); }); | |
| 22 } | |
| 23 | |
| 24 if (testTargets.length == 0) { | 18 if (testTargets.length == 0) { |
| 25 // Destroying the execution context while fetch is happening | 19 port.postMessage('quit'); |
| 26 // should not cause a crash. | 20 // Destroying the execution context while fetch is happening should not
cause a crash. |
| 27 runInfiniteFetchLoop(); | 21 fetch('dummy.html').then(function() {}).catch(function() {}); |
| 28 | 22 self.close(); |
| 29 port.postMessage('quit'); | 23 return; |
| 30 return; | |
| 31 } | 24 } |
| 32 var target = testTargets.shift(); | 25 var target = testTargets.shift(); |
| 33 fetch(target) | 26 fetch(target) |
| 34 .then(function(response) { | 27 .then(function(response) { |
| 35 port.postMessage('Resolved: ' + target + ' [' + response.status + ']' +
response.statusText); | 28 port.postMessage('Resolved: ' + target + ' [' + response.status + ']' +
response.statusText); |
| 36 doNextFetchTest(port); | 29 doNextFetchTest(port); |
| 37 }).catch(function(e) { | 30 }).catch(function(e) { |
| 38 port.postMessage('Rejected: ' + target + ' : '+ e.message); | 31 port.postMessage('Rejected: ' + target + ' : '+ e.message); |
| 39 doNextFetchTest(port); | 32 doNextFetchTest(port); |
| 40 }); | 33 }); |
| 41 }; | 34 }; |
| OLD | NEW |