Commit f1c5495f authored by Joey Arhar's avatar Joey Arhar Committed by Commit Bot

Don't insert tab characters into <input type=color> on mac

This is the same issue/fix as crrev.com/703403 but for mac.

On mac WebPagePopupImpl::HandleKeyEvent is called instead of
WebPagePopupImpl::HandleCharEvent, but I'm not sure why.

fast/forms/color/color-picker-no-tab-character.html should have already
been testing this, but when the test is run on mac it doesn't actually
insert tab characters into the input elements, which does happen when
testing it manually. After doing much debugging, I wasn't able to figure
out why, but I did find that keypress events are another observable side
effect which happens in parallel with inserting tab characters, so I
added a check for it to color-picker-no-tab-character.html as a test for
this change.

Fixes: 1146693
Bug: 1011168
Change-Id: Ib395fdad80d92452158c867bafb867e8db08e597
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2524290Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarSanket Joshi <sajos@microsoft.com>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825408}
parent 26497fe5
......@@ -160,7 +160,7 @@ class PagePopupChromeClient final : public EmptyChromeClient {
const String&,
const String&) override {
#ifndef NDEBUG
fprintf(stderr, "CONSOLE MESSSAGE:%u: %s\n", line_number,
fprintf(stderr, "CONSOLE MESSAGE:%u: %s\n", line_number,
message.Utf8().c_str());
#endif
}
......@@ -665,6 +665,11 @@ WebInputEventResult WebPagePopupImpl::HandleKeyEvent(
if (closing_)
return WebInputEventResult::kNotHandled;
if (suppress_next_keypress_event_) {
suppress_next_keypress_event_ = false;
return WebInputEventResult::kHandledSuppressed;
}
if (WebInputEvent::Type::kRawKeyDown == event.GetType()) {
Element* focused_element = FocusedElement();
if (event.windows_key_code == VKEY_TAB && focused_element &&
......
......@@ -24,6 +24,14 @@ t.step(() => {
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');
......@@ -38,4 +46,4 @@ t.step(() => {
});
</script>
</body>
</html>
\ No newline at end of file
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment