chromium/third_party/blink/web_tests/fast/forms/week/week-picker-select-value-with-keyboard.html

<!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="week" id="week0" value="2019-W07">
<input type="week" id="week1" value="2019-W07" step="2">
<input type="week" id="week2" value="2019-W07" step="2">
<input type="week" id="week3" value="2019-W07" step="5">
<input type="week" id="week4" value="2019-W07" min="2019-W06">
<input type="week" id="week5" value="2019-W07" max="2019-W08">
<script>
promise_test(() => {
  let weekElement = document.getElementById("week0");
  return openPicker(weekElement)
  .then(() => {
    eventSender.keyDown('ArrowRight');
    eventSender.keyDown('ArrowDown');
    assert_equals(weekElement.value, "2019-W09", "Using arrow keys to navigate week picker should update in-page control without pressing Enter key.");

    eventSender.keyDown('Enter');
    assert_equals(internals.pagePopupWindow, null, "Enter key should dismiss popup.");
    assert_equals(weekElement.value, "2019-W09", "Updated week should remain after closing popup with Enter.");
  });
}, "Week picker: Arrow keys should allow user to chooser week");

promise_test(() => {
  let weekElement = document.getElementById("week1");
  return openPicker(weekElement)
  .then(() => {
    eventSender.keyDown('ArrowRight');
    assert_equals(weekElement.value, "2019-W09", "Right arrow key should skip over invalid date.");

    eventSender.keyDown('Enter');
    assert_equals(internals.pagePopupWindow, null, "Enter key should dismiss popup.");
  });
}, "Week picker: Picker with step should allow keyboard user to jump over invalid values -- right arrow");

promise_test(() => {
  let weekElement = document.getElementById("week2");
  return openPicker(weekElement)
  .then(() => {
    eventSender.keyDown('ArrowUp');
    assert_equals(weekElement.value, "2019-W05", "Up arrow key should skip over invalid week.");

    eventSender.keyDown('Enter');
    assert_equals(internals.pagePopupWindow, null, "Enter key should dismiss popup.");
  });
}, "Week picker: Picker with step should allow keyboard user to jump over invalid values -- up arrow");

promise_test(() => {
  let weekElement = document.getElementById("week3");
  return openPicker(weekElement)
  .then(() => {
    eventSender.keyDown('ArrowDown');
    assert_equals(weekElement.value, "2019-W12", "Arrow key should skip to next valid week even if it's in a different month.");

    eventSender.keyDown('Enter');
    assert_equals(internals.pagePopupWindow, null, "Enter key should dismiss popup.");
  });
}, "Week picker: Picker with step should allow keyboard user to skip to next month with valid week");

promise_test(() => {
  let weekElement = document.getElementById("week4");
  return openPicker(weekElement)
  .then(() => {
    eventSender.keyDown('ArrowLeft');
    eventSender.keyDown('ArrowLeft');
    eventSender.keyDown('ArrowUp');
    assert_equals(weekElement.value, "2019-W06", "Min attribute should prevent user from arrowing into invalid values");

    eventSender.keyDown('Enter');
    assert_equals(internals.pagePopupWindow, null, "Enter key should dismiss popup.");
  });
}, "Week picker: Picker with min value should prevent user from using arrow keys to get into invalid values");

promise_test(() => {
  let weekElement = document.getElementById("week5");
  return openPicker(weekElement)
  .then(() => {
    eventSender.keyDown('ArrowDown');
    eventSender.keyDown('ArrowDown');
    eventSender.keyDown('ArrowRight');
    assert_equals(weekElement.value, "2019-W08", "Max attribute should prevent user from arrowing into invalid values");

    eventSender.keyDown('Enter');
    assert_equals(internals.pagePopupWindow, null, "Enter key should dismiss popup.");
  });
}, "Week picker: Picker with max value should prevent user from using arrow keys to get into invalid values");

</script>