<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
<html>
<meta name="viewport" content="width=device-width">
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/ui-helper.js"></script>
<script>
jsTestIsAsync = true;

async function runTest() {
    description(`This test verifies that the value in the time picker is updated on the second presentation of the form. To manually run the test, tap the time input and change the time to 9:41, then dismiss the picker, and select it again and verify that it says 9:41.`);

    time = document.querySelector("input");
    time.addEventListener("change", () => testPassed("Handled change event"));
    time.addEventListener("blur", () => testPassed("Handled blur event"));

    if (!window.testRunner)
        return;

    await UIHelper.activateElementAndWaitForInputSession(time);
    await UIHelper.setTimePickerValue(9, 41);
    await UIHelper.dismissFormAccessoryView();
    await UIHelper.waitForInputSessionToDismiss();
    await UIHelper.activateElementAndWaitForInputSession(time);
    pickerValues = await UIHelper.timerPickerValues();

    shouldBe("pickerValues.hour", "9");
    shouldBe("pickerValues.minute", "41");
    await UIHelper.dismissFormAccessoryView();
    await UIHelper.waitForInputSessionToDismiss();
    finishJSTest();
}
</script>
</head>
<body onload="runTest()">
<input type="time" value="04:01" style="width: 320px; height: 100px;"></input>
</body>
</html>
