<!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='../../../fast/forms/resources/picker-common.js'></script>
<input type='color' id='color' value='#80d9ff'>
<script>
'use strict';
let t = async_test('Color picker: Tabbing into a color value container should not insert a tab character.');
t.step(() => {
let colorControl = document.getElementById('color');
openPicker(colorControl)
.then(t.step_func_done(() => {
internals.pagePopupWindow.focus();
const popupDocument = internals.pagePopupWindow.document;
const rValueContainer = popupDocument.getElementById('rValueContainer');
const gValueContainer = popupDocument.getElementById('gValueContainer');
const bValueContainer = popupDocument.getElementById('bValueContainer');
assert_equals(rValueContainer.value, '128');
assert_equals(gValueContainer.value, '217');
assert_equals(bValueContainer.value, '255');
const hueSliderSelectionRing = popupDocument.querySelector('hue-slider > color-selection-ring');
hueSliderSelectionRing.focus();
[rValueContainer, gValueContainer, bValueContainer].forEach(container => {
container.addEventListener('keypress', t.step_func(event => {
assert_not_equals(event.key, 'Tab',
'If tab key suppression was successful, there should be no keypress event for it.');
}));
});
assert_equals(popupDocument.activeElement, hueSliderSelectionRing);
eventSender.keyDown('Tab');
assert_equals(popupDocument.activeElement, rValueContainer, 'rValueContainer should be the active element');
assert_equals(rValueContainer.value, '128', 'rValueContainer\'s value should not have changed');
eventSender.keyDown('Tab');
assert_equals(popupDocument.activeElement, gValueContainer, 'gValueContainer should be the active element');
assert_equals(gValueContainer.value, '217', 'gValueContainer\'s value should not have changed');
eventSender.keyDown('Tab');
assert_equals(popupDocument.activeElement, bValueContainer, 'bValueContainer should be the active element');
assert_equals(bValueContainer.value, '255', 'bValueContainer\'s value should not have changed');
}));
});
</script>