chromium/third_party/blink/web_tests/fast/forms/color/color-picker-tab-navigation.html

<!DOCTYPE html>
<meta name=fuzzy content="maxDifference=0-3; totalPixels=0-1000">
<script>
testRunner.dumpAsText();
testRunner.waitUntilDone();
</script>
<script src="../../../resources/testdriver.js"></script>
<script src="../../../resources/testdriver-vendor.js"></script>
<script src='../../../fast/forms/resources/picker-common.js'></script>

<input type='color' id='color'>

<p id='description' style='opacity: 0'></p>
<div id='console' style='opacity: 0'></div>

<script>
let descriptionContainer = document.getElementById('description');
openPickerDeprecatedJsTest(document.getElementById('color'), openPickerCallback, openPickerCallback);

function openPickerCallback() {
  if (internals.pagePopupWindow) {
    descriptionContainer.append('Popup opened.', document.createElement('br'));
    internals.pagePopupWindow.focus();
    const popupDocument = internals.pagePopupWindow.document;
    const formatToggler = popupDocument.querySelector('format-toggler');
    tabNavigateAndLogFocusableElements(popupDocument);
    changeActiveColorFormat(formatToggler);
    tabNavigateAndLogFocusableElements(popupDocument);
    changeActiveColorFormat(formatToggler);
    tabNavigateAndLogFocusableElements(popupDocument);
  } else {
    descriptionContainer.append('Popup did not open.', document.createElement('br'));
  }
  descriptionContainer.append('TEST COMPLETE');
  testRunner.notifyDone();
}

function changeActiveColorFormat(formatToggler) {
  formatToggler.click();  // first click changes format to HSL, second click changes format to Hex
  descriptionContainer.append(formatToggler.tagName + ' clicked. Active color format changed.', document.createElement('br'));
}

function tabNavigateAndLogFocusableElements(popupDocument) {
  const focusableElements = popupDocument
      .querySelectorAll('color-value-container:not(.hidden-color-value-container) > input, ' +
                        '[tabindex]:not([tabindex=\'-1\'])');
  for(let i = 0; i < focusableElements.length; i++) {
    eventSender.keyDown('Tab');
    if (popupDocument.activeElement.hasAttribute('id')) {
      descriptionContainer.append(popupDocument.activeElement.getAttribute('id').toUpperCase());
    } else {
      descriptionContainer.append(popupDocument.activeElement.tagName);
    }
    descriptionContainer.append(document.createElement('br'));
  }
}
</script>