| Index: third_party/WebKit/LayoutTests/battery-status/multiple-windows-page-visibility.html
|
| diff --git a/third_party/WebKit/LayoutTests/battery-status/multiple-windows-page-visibility.html b/third_party/WebKit/LayoutTests/battery-status/multiple-windows-page-visibility.html
|
| index 230f148b4d8c8d6ca48c662b0df24f45d403c1f7..9e25ea165d97302c7f65fc208d70a8b4029d7d84 100644
|
| --- a/third_party/WebKit/LayoutTests/battery-status/multiple-windows-page-visibility.html
|
| +++ b/third_party/WebKit/LayoutTests/battery-status/multiple-windows-page-visibility.html
|
| @@ -2,13 +2,13 @@
|
| <html>
|
| <body>
|
| <script src="../resources/js-test.js"></script>
|
| +<script src="../resources/mojo-helpers.js"></script>
|
| +<script src="resources/mock-battery-monitor.js"></script>
|
| <script>
|
| description("Test multiple windows with page visibility.");
|
|
|
| if (!window.testRunner)
|
| debug('This test cannot be run without the TestRunner');
|
| -if (!window.internals)
|
| - debug('This test cannot be run without the window.internals');
|
|
|
| // Clean-up any unused battery manager objects from previous tests.
|
| gc();
|
| @@ -17,36 +17,11 @@ testRunner.waitUntilDone();
|
| testRunner.setCanOpenWindows();
|
| testRunner.setCloseRemainingWindowsWhenComplete(true);
|
|
|
| -var mockBatteryInfo;
|
| -function setAndFireMockBatteryInfo(charging, chargingTime, dischargingTime, level) {
|
| - mockBatteryInfo = { charging: charging,
|
| - chargingTime: chargingTime,
|
| - dischargingTime: dischargingTime,
|
| - level: level };
|
| - window.internals.updateBatteryStatus(charging, chargingTime, dischargingTime, level);
|
| -}
|
| -
|
| -// compare obtained battery values with the mock values
|
| -function checkBatteryInfo(batteryManager) {
|
| - batteryInfo = batteryManager;
|
| - shouldBeDefined("batteryInfo");
|
| - shouldBeDefined("mockBatteryInfo");
|
| - shouldBe('batteryInfo.charging', 'mockBatteryInfo.charging');
|
| - shouldBe('batteryInfo.chargingTime', 'mockBatteryInfo.chargingTime');
|
| - shouldBe('batteryInfo.dischargingTime', 'mockBatteryInfo.dischargingTime');
|
| - shouldBe('batteryInfo.level', 'mockBatteryInfo.level');
|
| -}
|
| -
|
| -function batteryStatusFailure() {
|
| - testFailed('failed to successfully resolve the promise');
|
| - setTimeout(finishJSTest, 0);
|
| -}
|
| -
|
| var battery;
|
| function batteryStatusSuccess(batteryManager) {
|
| battery = batteryManager;
|
| debug('resolution in window');
|
| - checkBatteryInfo(battery);
|
| + testIfBatteryStatusIsUpToDate(battery);
|
| battery.addEventListener('levelchange', failAndFinish);
|
|
|
| firstWindow = window;
|
| @@ -54,7 +29,7 @@ function batteryStatusSuccess(batteryManager) {
|
| secondWindow.navigator.getBattery().then(
|
| function(battery2) {
|
| debug('resolution in secondWindow');
|
| - checkBatteryInfo(battery2);
|
| + testIfBatteryStatusIsUpToDate(battery2);
|
| setTimeout(fireNewMockLevel, 0);
|
| }, batteryStatusFailure);
|
|
|
| @@ -75,7 +50,7 @@ function proceedToVisible() {
|
| }
|
|
|
| function onLevelChange() {
|
| - checkBatteryInfo(battery);
|
| + testIfBatteryStatusIsUpToDate(battery);
|
| battery.removeEventListener('levelchange', onLevelChange);
|
| setTimeout(finishJSTest, 0);
|
| }
|
| @@ -86,8 +61,10 @@ function failAndFinish() {
|
| }
|
|
|
| debug("first window: page is visible");
|
| -navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure);
|
| -setAndFireMockBatteryInfo(false, 10, 20, 0.5);
|
| +mockBatteryMonitorReady.then(() => {
|
| + navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure);
|
| + setAndFireMockBatteryInfo(false, 10, 20, 0.5);
|
| +});
|
| </script>
|
| </body>
|
| </html>
|
|
|