<!DOCTYPE html>
<meta name=fuzzy content="maxDifference=0-3; totalPixels=0-1000">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/testdriver.js"></script>
<script src="../../../resources/testdriver-vendor.js"></script>
<script src="../resources/common.js"></script>
<script src="../resources/picker-common.js"></script>
<script src="../calendar-picker/resources/calendar-picker-common.js"></script>
<input type="date" value="2021-07-15">
<input type="date" value="2021-07-15" required>
<input type="week" value="2021-W01">
<input type="week" value="2021-W01" required>
<input type="datetime-local" value="2021-07-15T00:00" >
<input type="datetime-local" value="2021-07-15T00:00" required>
<script>
document.querySelectorAll('input').forEach(element => {
promise_test(() => {
return openPicker(element)
.then(() => {
// Make the picker dismiss synchronously so we don't need to insert
// an artificial delay in the test
internals.pagePopupWindow.CalendarPicker.commitDelayMs = 0;
clickClearButton();
assert_equals(element.value, "", "Clear button should have updated in-page control to empty string.");
assert_equals(internals.pagePopupWindow, null, "Click on Clear button should close popup.");
});
}, `Calendar picker: Clear button for ${element.outerHTML} should clear date`);
});
</script>