<!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/gesture-util.js"></script>
<script src="../resources/common.js"></script>
<script src="../resources/common-wheel-event.js"></script>
<script src="../resources/picker-common.js"></script>
<script src="resources/suggestion-picker-common.js"></script>
<body style="background-color: #bbbbbb;">
<input type=month value="2012-12" list=suggestions>
<datalist id=suggestions>
<option label="This Month">2012-01</option>
<option>2012-02</option>
<option>2012-03</option>
<option>2012-04</option>
<option>2012-05</option>
<option>2012-06</option>
<option>2012-07</option>
<option>2012-08</option>
<option>2012-09</option>
<option>2012-10</option>
<option>2012-11</option>
<option>2012-12</option>
<option>2013-01</option>
<option>2013-02</option>
<option>2013-03</option>
<option>2013-04</option>
<option>2013-05</option>
<option>2013-06</option>
<option>2013-07</option>
<option>2013-08</option>
<option>2013-09</option>
<option>2013-10</option>
<option>2013-11</option>
<option>2013-12</option>
<option>2014-01</option>
<option>2014-02</option>
<option>2014-03</option>
<option>2014-04</option>
<option>2014-05</option>
<option>2014-06</option>
<option>2014-07</option>
<option>2014-08</option>
<option>2014-09</option>
<option>2014-10</option>
<option>2014-11</option>
<option>2014-12</option>
<option>2015-01</option>
<option>2015-02</option>
<option>2015-03</option>
<option>2015-04</option>
<option>2015-05</option>
<option>2015-06</option>
<option>2015-07</option>
<option>2015-08</option>
<option>2015-09</option>
<option>2015-10</option>
<option>2015-11</option>
<option>2015-12</option>
<option>2012-00</option> <!--invalid-->
<option>2012-01-01</option> <!--invalid-->
<option>foo</option> <!--invalid-->
</datalist>
<script>
window.onload = () => {
if (window.internals)
internals.settings.setScrollAnimatorEnabled(false);
const element = document.querySelector('input');
promise_test(() => {
return openPicker(element)
.then(() => {
hoverOverElement(internals.pagePopupWindow.document.querySelector(".suggestion-list-entry:nth-child(2)"));
assert_equals(highlightedEntry(), '2012-01-02');
hoverOverElement(document.getElementById('otherelement'));
assert_true(!highlightedEntry());
clickElement(internals.pagePopupWindow.document.querySelector(".suggestion-list-entry:nth-child(3)"));
return attemptToClosePicker(element);
})
.then(() => {
assert_true(!internals.pagePopupWindow);
});
},'Check basic hover operation');
promise_test(() => {
let suggestionList;
let savedScrollTop;
return openPicker(element)
.then(() => {
suggestionList = internals.pagePopupWindow.document.getElementsByClassName("suggestion-list")[0];
savedScrollTop = suggestionList.scrollTop;
return dispatchWheelEvent(suggestionList, 0, 3);
})
.then(() => {
return waitFor(() => savedScrollTop < suggestionList.scrollTop);
})
.then(() => {
savedScrollTop = suggestionList.scrollTop;
return dispatchWheelEvent(suggestionList, 0, -3);
})
.then(() => {
return waitFor(() => savedScrollTop > suggestionList.scrollTop);
})
.then(() => {
internals.pagePopupWindow.focus();
return attemptToClosePicker(element);
});
},'Scroll using the mouse wheel');
promise_test(() => {
let suggestionList;
return openPicker(element)
.then(() => {
suggestionList = internals.pagePopupWindow.document.getElementsByClassName("suggestion-list")[0];
var suggestionListOffset = cumulativeOffset(suggestionList);
var scrollbarCenterX = suggestionListOffset[0] + suggestionList.offsetWidth - internals.pagePopupWindow.getScrollbarWidth() / 2;
savedScrollTop = suggestionList.scrollTop;
eventSender.mouseMoveTo(scrollbarCenterX, suggestionListOffset[1] + 20); // 20 is the height of the up arrow button plus a few pixels
eventSender.mouseDown();
eventSender.mouseMoveTo(scrollbarCenterX, suggestionListOffset[1] + suggestionList.offsetHeight);
eventSender.mouseUp();
})
.then(() => requestAnimationFramePromise())
.then(() => {
scrollTopAfterWheelEvent = suggestionList.scrollTop;
assert_true(savedScrollTop < scrollTopAfterWheelEvent);
return attemptToClosePicker(element);
})
},'Scroll using the scroll bar');
};
</script>