Commit b68142a1 authored by Ionel Popescu's avatar Ionel Popescu Committed by Commit Bot

Ensure that WebFrameWidgetImpl hands char events off to an open popup.

This CL addresses an issue where the users where not able to enter data
into the text fields of the color picker when the elements are inside
a cross-domain iframe.

For the top-level page and for same-domain iframes, when a char event
is received while a popup is open, the event is routed from
RenderWidgetInputHandler to WebViewFrameWidget shim, which hands it to
the WebView. WebViewImpl::HandleCharEvent has code to check for an open
popup and the event is sent to the popup if one exists.

For the cross-domain iframe case, the RenderWidgetInputHandler hands
the event to WebFrameWidgetImpl, but WebFrameWidgetImpl::HandleCharEvent
doesn't check for an open popup, so the event goes to the page
containing the popup.

This CL adds the same popup check to WebFrameWidgetImpl as the one that
WebViewImpl::HandleCharEvent already has.

Bug: 1114052
Change-Id: I33f2b10b4ae5aa538ebb0d22c1d55f5d97019216
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364008Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Ionel Popescu <iopopesc@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#799458}
parent c646fd26
...@@ -976,6 +976,12 @@ WebInputEventResult WebFrameWidgetImpl::HandleCharEvent( ...@@ -976,6 +976,12 @@ WebInputEventResult WebFrameWidgetImpl::HandleCharEvent(
bool suppress = suppress_next_keypress_event_; bool suppress = suppress_next_keypress_event_;
suppress_next_keypress_event_ = false; suppress_next_keypress_event_ = false;
// If there is a popup open, it should be the one processing the event,
// not the page.
scoped_refptr<WebPagePopupImpl> page_popup = View()->GetPagePopup();
if (page_popup)
return page_popup->HandleKeyEvent(event);
LocalFrame* frame = To<LocalFrame>(FocusedCoreFrame()); LocalFrame* frame = To<LocalFrame>(FocusedCoreFrame());
if (!frame) { if (!frame) {
return suppress ? WebInputEventResult::kHandledSuppressed return suppress ? WebInputEventResult::kHandledSuppressed
......
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body >
<script>
let t = async_test("Test input color popup's keyboard usability when inside cross-process iframe.");
let iframe = document.createElement("iframe");
iframe.src = "http://localhost:8000/forms/resources/color-picker-keyboard-cross-domain-iframe.html";
const runTest = t.step_func((event) => {
// The eventSender.keyDown() invocations in the iframe create extra window messages.
// Ignore those.
if (typeof(event.data) !== "string" || !event.data.includes("Color result:")) {
return;
}
// iframe should be cross-origin (and cross-process)
assert_equals(iframe.contentDocument, null);
assert_equals(event.data, "Color result: 50");
t.done();
}, "Check rValueContainer in cross-domain iframe.");
window.onmessage = runTest;
document.body.appendChild(iframe);
</script>
</body>
</html>
<html>
<input type="color" id="color" value="#126465">
<script>
let colorElement = document.getElementById('color');
// Open color picker.
colorElement.focus();
eventSender.keyDown(" ");
internals.pagePopupWindow.focus();
const popupDocument = internals.pagePopupWindow.document;
const rValueContainer = popupDocument.getElementById('rValueContainer');
rValueContainer.focus();
eventSender.keyDown("Backspace");
eventSender.keyDown("Backspace");
eventSender.keyDown("5");
eventSender.keyDown("0");
window.top.postMessage(`Color result: ${rValueContainer.value}`, "*");
</script>
</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