| 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 windows with page visibility."); | 6 description("Test multiple windows with page visibility."); |
| 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'); | |
| 12 | 10 |
| 13 // Clean-up any unused battery manager objects from previous tests. | 11 // Clean-up any unused battery manager objects from previous tests. |
| 14 gc(); | 12 gc(); |
| 15 jsTestIsAsync = true; | 13 jsTestIsAsync = true; |
| 16 testRunner.waitUntilDone(); | 14 testRunner.waitUntilDone(); |
| 17 testRunner.setCanOpenWindows(); | 15 testRunner.setCanOpenWindows(); |
| 18 testRunner.setCloseRemainingWindowsWhenComplete(true); | 16 testRunner.setCloseRemainingWindowsWhenComplete(true); |
| 19 | 17 |
| 20 var mockBatteryInfo; | 18 var mockBatteryInfo; |
| 21 function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, leve
l) { | 19 function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, leve
l) { |
| 22 mockBatteryInfo = { charging: charging, | 20 mockBatteryInfo = { charging: charging, |
| 23 chargingTime: chargingTime, | 21 chargingTime: chargingTime, |
| 24 dischargingTime: dischargingTime, | 22 dischargingTime: dischargingTime, |
| 25 level: level }; | 23 level: level }; |
| 26 window.internals.updateBatteryStatus(charging, chargingTime, dischargingTime
, level); | 24 testRunner.didChangeBatteryStatus(charging, chargingTime, dischargingTime, l
evel); |
| 27 } | 25 } |
| 28 | 26 |
| 29 // compare obtained battery values with the mock values | 27 // compare obtained battery values with the mock values |
| 30 function checkBatteryInfo(batteryManager) { | 28 function checkBatteryInfo(batteryManager) { |
| 31 batteryInfo = batteryManager; | 29 batteryInfo = batteryManager; |
| 32 shouldBeDefined("batteryInfo"); | 30 shouldBeDefined("batteryInfo"); |
| 33 shouldBeDefined("mockBatteryInfo"); | 31 shouldBeDefined("mockBatteryInfo"); |
| 34 shouldBe('batteryInfo.charging', 'mockBatteryInfo.charging'); | 32 shouldBe('batteryInfo.charging', 'mockBatteryInfo.charging'); |
| 35 shouldBe('batteryInfo.chargingTime', 'mockBatteryInfo.chargingTime'); | 33 shouldBe('batteryInfo.chargingTime', 'mockBatteryInfo.chargingTime'); |
| 36 shouldBe('batteryInfo.dischargingTime', 'mockBatteryInfo.dischargingTime'); | 34 shouldBe('batteryInfo.dischargingTime', 'mockBatteryInfo.dischargingTime'); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 testFailed('received event while the page was hidden'); | 82 testFailed('received event while the page was hidden'); |
| 85 setTimeout(finishJSTest, 0); | 83 setTimeout(finishJSTest, 0); |
| 86 } | 84 } |
| 87 | 85 |
| 88 debug("first window: page is visible"); | 86 debug("first window: page is visible"); |
| 89 navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure); | 87 navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure); |
| 90 setAndFireMockBatteryInfo(false, 10, 20, 0.5); | 88 setAndFireMockBatteryInfo(false, 10, 20, 0.5); |
| 91 </script> | 89 </script> |
| 92 </body> | 90 </body> |
| 93 </html> | 91 </html> |
| OLD | NEW |