blob: 10d73bbae2bd3c0dce8d7817eb6ef560fa225edd [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../resources/js-test.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/services/device/public/interfaces/battery_monitor.mojom.js"></script>
<script src="resources/mock-battery-monitor.js"></script>
<script>
description("Test battery status API with multiple windows.");
if (!window.testRunner)
debug('This test cannot be run without the TestRunner');
// Clean-up any unused battery manager objects from previous tests.
gc();
jsTestIsAsync = true;
testRunner.waitUntilDone();
testRunner.setCanOpenWindows();
testRunner.setCloseRemainingWindowsWhenComplete(true);
function batteryStatusSuccess(battery) {
debug('resolution in window');
testIfBatteryStatusIsUpToDate(battery);
secondWindow = window.open("");
secondWindow.navigator.getBattery().then(
function(battery2) {
debug('resolution in secondWindow');
testIfBatteryStatusIsUpToDate(battery2);
setTimeout(finishJSTest, 0);
}, batteryStatusFailure);
}
navigator.getBattery().then(batteryStatusSuccess, batteryStatusFailure);
setAndFireMockBatteryInfo(false, 10, 20, 0.5);
</script>
</body>
</html>