<!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/picker-common.js"></script>
<script src="resources/suggestion-picker-common.js"></script>
<body style="background-color: #bbbbbb;">
<input type=datetime-local value="2012-11-22T00:00" step="3600" list=suggestions>
<datalist id=suggestions>
<option>2012-11-22T01:00</option>
<option>2012-11-22T01:00:01</option>
<option>2012-11-22T01:00:01.001</option>
<option>2012-11-22T01:00:01.010</option>
<option>2012-11-22T01:01</option>
<option>2012-11-22T02:00</option>
<option>2012-11-22T02:01</option>
</datalist>
<script>
window.onload = () => {
const element = document.querySelector('input');
promise_test(() => {
return openPicker(element)
.then(() => {
internals.pagePopupWindow.focus();
assert_equals(entryValues().length, 3);
assert_equals(entryValues()[0], '2012-11-22T01:00');
assert_equals(entryValues()[1], '2012-11-22T02:00');
assert_equals(entryValues()[2], '@openCalendarPicker');
return attemptToClosePicker(element);
});
},'Step attribute filters out suggestions');
promise_test(() => {
element.step = 60;
return openPicker(element)
.then(() => {
internals.pagePopupWindow.focus();
assert_equals(entryValues().length, 5);
assert_equals(entryValues()[0], '2012-11-22T01:00');
assert_equals(entryValues()[1], '2012-11-22T01:01');
assert_equals(entryValues()[2], '2012-11-22T02:00');
assert_equals(entryValues()[3], '2012-11-22T02:01');
assert_equals(entryValues()[4], '@openCalendarPicker');
return attemptToClosePicker(element);
});
},'Step attribute filters out suggestions - longer step');
promise_test(() => {
element.step = 1;
return openPicker(element)
.then(() => {
internals.pagePopupWindow.focus();
assert_equals(entryValues().length, 6);
assert_equals(entryValues()[0], '2012-11-22T01:00');
assert_equals(entryValues()[1], '2012-11-22T01:00:01');
assert_equals(entryValues()[2], '2012-11-22T01:01');
assert_equals(entryValues()[3], '2012-11-22T02:00');
assert_equals(entryValues()[4], '2012-11-22T02:01');
assert_equals(entryValues()[5], '@openCalendarPicker');
return attemptToClosePicker(element);
});
},'Step attribute filters out suggestions - short step');
promise_test(() => {
element.step = 0.001;
return openPicker(element)
.then(() => {
internals.pagePopupWindow.focus();
assert_equals(entryValues().length, 8);
assert_equals(entryValues()[0], '2012-11-22T01:00');
assert_equals(entryValues()[1], '2012-11-22T01:00:01');
assert_equals(entryValues()[2], '2012-11-22T01:00:01.001');
assert_equals(entryValues()[3], '2012-11-22T01:00:01.010');
assert_equals(entryValues()[4], '2012-11-22T01:01');
assert_equals(entryValues()[5], '2012-11-22T02:00');
assert_equals(entryValues()[6], '2012-11-22T02:01');
assert_equals(entryValues()[7], '@openCalendarPicker');
return attemptToClosePicker(element);
});
},'Step attribute filters out suggestions - very short step');
};
</script>