blob: 48130fcd09fbceaf24ff033751ec790d1e5fdb10 [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/mojom/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>