| 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 if (!window.internals) |
| 11 debug('This test cannot be run without the window.internals'); |
| 10 | 12 |
| 11 // Clean-up any unused battery manager objects from previous tests. | 13 // Clean-up any unused battery manager objects from previous tests. |
| 12 gc(); | 14 gc(); |
| 13 jsTestIsAsync = true; | 15 jsTestIsAsync = true; |
| 14 testRunner.waitUntilDone(); | 16 testRunner.waitUntilDone(); |
| 15 testRunner.setCanOpenWindows(); | 17 testRunner.setCanOpenWindows(); |
| 16 testRunner.setCloseRemainingWindowsWhenComplete(true); | 18 testRunner.setCloseRemainingWindowsWhenComplete(true); |
| 17 | 19 |
| 18 var mockBatteryInfo; | 20 var mockBatteryInfo; |
| 19 function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, leve
l) { | 21 function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, leve
l) { |
| 20 mockBatteryInfo = { charging: charging, | 22 mockBatteryInfo = { charging: charging, |
| 21 chargingTime: chargingTime, | 23 chargingTime: chargingTime, |
| 22 dischargingTime: dischargingTime, | 24 dischargingTime: dischargingTime, |
| 23 level: level }; | 25 level: level }; |
| 24 testRunner.didChangeBatteryStatus(charging, chargingTime, dischargingTime, l
evel); | 26 window.internals.updateBatteryStatus(charging, chargingTime, dischargingTime
, level); |
| 25 } | 27 } |
| 26 | 28 |
| 27 // compare obtained battery values with the mock values | 29 // compare obtained battery values with the mock values |
| 28 function checkBatteryInfo(batteryManager) { | 30 function checkBatteryInfo(batteryManager) { |
| 29 batteryInfo = batteryManager; | 31 batteryInfo = batteryManager; |
| 30 shouldBeDefined("batteryInfo"); | 32 shouldBeDefined("batteryInfo"); |
| 31 shouldBeDefined("mockBatteryInfo"); | 33 shouldBeDefined("mockBatteryInfo"); |
| 32 shouldBe('batteryInfo.charging', 'mockBatteryInfo.charging'); | 34 shouldBe('batteryInfo.charging', 'mockBatteryInfo.charging'); |
| 33 shouldBe('batteryInfo.chargingTime', 'mockBatteryInfo.chargingTime'); | 35 shouldBe('batteryInfo.chargingTime', 'mockBatteryInfo.chargingTime'); |
| 34 shouldBe('batteryInfo.dischargingTime', 'mockBatteryInfo.dischargingTime'); | 36 shouldBe('batteryInfo.dischargingTime', 'mockBatteryInfo.dischargingTime'); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 64 checkBatteryInfo(battery); | 66 checkBatteryInfo(battery); |
| 65 promise2Count++; | 67 promise2Count++; |
| 66 finishIfReady(); | 68 finishIfReady(); |
| 67 }, batteryStatusFailure); | 69 }, batteryStatusFailure); |
| 68 | 70 |
| 69 shouldBeTrue('promise1 === promise2'); | 71 shouldBeTrue('promise1 === promise2'); |
| 70 setAndFireMockBatteryInfo(false, 10, 20, 0.5); | 72 setAndFireMockBatteryInfo(false, 10, 20, 0.5); |
| 71 </script> | 73 </script> |
| 72 </body> | 74 </body> |
| 73 </html> | 75 </html> |
| OLD | NEW |