<!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>
<iframe></iframe>
<script>
window.onload = () => {
const iframe = document.querySelector('iframe');
const iframeLoaded = new Promise(resolve => iframe.addEventListener('load',resolve,{once:true}));
iframe.srcdoc = '<input type=date id=test1 list=suggestions><input type=date id=test2 value=2002-02-02 list=suggestions><datalist id=suggestions><option>2012-01-01</option></datalist>';
let element;
promise_test(() => {
return iframeLoaded
.then(() => {
element = iframe.contentDocument.getElementById('test1');
return openPicker(element);
})
.then(() => {
internals.pagePopupWindow.focus();
assert_true(!highlightedEntry());
eventSender.keyDown('ArrowDown');
assert_equals(highlightedEntry(), '2012-01-01');
eventSender.keyDown('Enter');
return attemptToClosePicker(element);
})
.then(() => {
assert_true(!internals.pagePopupWindow);
assert_equals(element.value, '2012-01-01');
})
.then(() => {
element = iframe.contentDocument.getElementById('test2');
return openPicker(element);
})
.then(() => {
internals.pagePopupWindow.focus();
assert_true(!highlightedEntry());
eventSender.keyDown('ArrowDown');
assert_equals(highlightedEntry(), '2012-01-01');
eventSender.keyDown('Enter');
return attemptToClosePicker(element);
})
.then(() => {
assert_true(!internals.pagePopupWindow);
assert_equals(element.value, '2012-01-01');
const iframeReloaded = new Promise(resolve => iframe.addEventListener('load',resolve,{once:true}));
iframe.contentWindow.location.reload();
return iframeReloaded;
})
.then(() => {
assert_equals(iframe.contentDocument.getElementById('test1').value, '');
assert_equals(iframe.contentDocument.getElementById('test2').value, '2002-02-02');
iframe.remove();
});
},'Checks reloading page resets input values');
};
</script>