| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <body> | 3 <body> |
| 4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 description("Test multiple promise resolution."); | 6 description("Test multiple promise resolution."); |
| 7 | 7 |
| 8 if (!window.testRunner) | 8 if (!window.testRunner) |
| 9 debug('This test cannot be run without the TestRunner'); | 9 debug('This test cannot be run without the TestRunner'); |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 var promise1Count = 0; | 43 var promise1Count = 0; |
| 44 var promise2Count = 0; | 44 var promise2Count = 0; |
| 45 | 45 |
| 46 function finishIfReady() { | 46 function finishIfReady() { |
| 47 if (promise1Count == 1 && promise2Count == 1) | 47 if (promise1Count == 1 && promise2Count == 1) |
| 48 setTimeout(finishJSTest, 0); | 48 setTimeout(finishJSTest, 0); |
| 49 } | 49 } |
| 50 | 50 |
| 51 promise1 = navigator.getBattery().then( | 51 promise1 = navigator.getBattery(); |
| 52 promise1.then( |
| 52 function(battery) { | 53 function(battery) { |
| 53 debug('first resolution'); | 54 debug('first resolution'); |
| 54 checkBatteryInfo(battery); | 55 checkBatteryInfo(battery); |
| 55 promise1Count++; | 56 promise1Count++; |
| 56 finishIfReady(); | 57 finishIfReady(); |
| 57 }, batteryStatusFailure); | 58 }, batteryStatusFailure); |
| 58 | 59 |
| 59 promise2 = navigator.getBattery().then( | 60 promise2 = navigator.getBattery(); |
| 61 promise2.then( |
| 60 function(battery) { | 62 function(battery) { |
| 61 debug('second resolution'); | 63 debug('second resolution'); |
| 62 checkBatteryInfo(battery); | 64 checkBatteryInfo(battery); |
| 63 promise2Count++; | 65 promise2Count++; |
| 64 finishIfReady(); | 66 finishIfReady(); |
| 65 }, batteryStatusFailure); | 67 }, batteryStatusFailure); |
| 66 | 68 |
| 67 shouldBeFalse('promise1 === promise2'); | 69 shouldBeTrue('promise1 === promise2'); |
| 68 setAndFireMockBatteryInfo(false, 10, 20, 0.5); | 70 setAndFireMockBatteryInfo(false, 10, 20, 0.5); |
| 69 </script> | 71 </script> |
| 70 </body> | 72 </body> |
| 71 </html> | 73 </html> |
| OLD | NEW |