Commit 5bfa90e5 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

SELECT element: Update menulist label when a user changes selection status

We missed to update textContent of a shadow node when
SelectMultipleOptionsByPopup() is called.
This issue affects only Android.

* html_select_element.cc:
  Update a shadow node content in |HTMLSelectElement::
  SelectMultipleOptionsByPopup()|.


* html_select_element_test.cc:
  Add a test case.

* test_blink_web_unit_test_support.cc:
  Fix a mock QueryLocalizedString() so that we can see different
  resultant strings depending on |value| argument.  The new behavior
  is similar to the QueryLocalizedString() implementation in production.

Bug: 1090247
Change-Id: I6d99e69dda6fc833eaa697daa304a8cd7a9d24ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2226581
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Auto-Submit: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774481}
parent 9d5006d6
......@@ -243,7 +243,7 @@ blink::WebString TestBlinkWebUnitTestSupport::QueryLocalizedString(
case IDS_FORM_VALIDATION_RANGE_OVERFLOW:
return blink::WebString::FromASCII("range overflow");
case IDS_FORM_SELECT_MENU_LIST_TEXT:
return blink::WebString::FromASCII("$1 selected");
return blink::WebString::FromASCII(value.Ascii() + " selected");
}
return BlinkPlatformImpl::QueryLocalizedString(resource_id, value);
......
......@@ -201,6 +201,7 @@ void HTMLSelectElement::SelectMultipleOptionsByPopup(
}
}
select_type_->UpdateTextStyleAndContent();
SetNeedsValidityCheck();
if (has_new_selection || !old_selection.IsEmpty()) {
DispatchInputEvent();
......
......@@ -50,6 +50,11 @@ class HTMLSelectElementTest : public PageTestBase {
return select->isConnected();
}
String MenuListLabel() const {
auto* select = To<HTMLSelectElement>(GetDocument().body()->firstChild());
return select->InnerElement().textContent();
}
private:
bool original_delegates_flag_;
};
......@@ -569,6 +574,16 @@ TEST_F(HTMLSelectElementTest, SelectMultipleOptionsByPopup) {
EXPECT_FALSE(FirstSelectIsConnectedAfterSelectMultiple(Vector<int>{1}))
<< "Onchange handler should be executed.";
}
// Check if the label is correctly updated.
{
SetHtmlInnerHTML(
"<select multiple>"
"<option selected>o0</option><option selected>o1</option></select>");
EXPECT_EQ("2 selected", MenuListLabel());
EXPECT_TRUE(FirstSelectIsConnectedAfterSelectMultiple(Vector<int>{1}));
EXPECT_EQ("o1", MenuListLabel());
}
}
TEST_F(HTMLSelectElementTest, IntrinsicInlineSizeOverflow) {
......
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