| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <body> | 2 <body> |
| 3 <script src="/js-test-resources/js-test.js"></script> | 3 <script src="/js-test-resources/js-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 (function() { | 5 (function() { |
| 6 description('Make two XHRs for the resource which is already cached.'); | 6 description('Make two XHRs for the resource which is already cached.'); |
| 7 window.jsTestIsAsync = true; | 7 window.jsTestIsAsync = true; |
| 8 var url = 'resources/get.txt'; | 8 var url = 'resources/get.txt'; |
| 9 function get(xhr, async) { | 9 function get(xhr, async) { |
| 10 return new Promise(function(resolve, reject) { | 10 return new Promise(function(resolve, reject) { |
| 11 xhr.onreadystatechange = function() { | 11 setTimeout(function() { |
| 12 if (xhr.readyState === xhr.DONE) { | 12 xhr.onreadystatechange = function() { |
| 13 if (xhr.status === 200) { | 13 if (xhr.readyState === xhr.DONE) { |
| 14 resolve(xhr.responseText); | 14 if (xhr.status === 200) { |
| 15 } else { | 15 resolve(xhr.responseText); |
| 16 reject(xhr.status); | 16 } else { |
| 17 reject(xhr.status); |
| 18 } |
| 17 } | 19 } |
| 18 } | 20 }; |
| 19 }; | 21 xhr.open('GET', url, async); |
| 20 xhr.open('GET', url, async); | 22 xhr.send(); |
| 21 xhr.send(); | 23 }, 0); |
| 22 }); | 24 }); |
| 23 } | 25 } |
| 24 var xhr1 = new XMLHttpRequest(); | 26 var xhr1 = new XMLHttpRequest(); |
| 25 var xhr2 = new XMLHttpRequest(); | 27 var xhr2 = new XMLHttpRequest(); |
| 26 | 28 |
| 27 Promise.resolve().then(function() { | 29 Promise.resolve().then(function() { |
| 28 var async = get(xhr1, true); | 30 var async = get(xhr1, true); |
| 29 var sync = get(xhr2, false); | 31 var sync = get(xhr2, false); |
| 30 return Promise.all([sync, async]); | 32 return Promise.all([sync, async]); |
| 31 }).then(function(results) { | 33 }).then(function(results) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 42 } | 44 } |
| 43 }, function(e) { | 45 }, function(e) { |
| 44 testFailed(e); | 46 testFailed(e); |
| 45 finishJSTest(); | 47 finishJSTest(); |
| 46 }); | 48 }); |
| 47 }()); | 49 }()); |
| 48 | 50 |
| 49 </script> | 51 </script> |
| 50 </body> | 52 </body> |
| 51 </html> | 53 </html> |
| OLD | NEW |