Bug 1646907 [wpt PR 24247] - SELECT element: Fix a regression on adding multiple...
commit8f2bd298c09b57640a786175421f18a519c02b17
authorKent Tamura <tkent@chromium.org>
Mon, 22 Jun 2020 10:44:45 +0000 (22 10:44 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Tue, 23 Jun 2020 11:04:44 +0000 (23 11:04 +0000)
tree277db97dab56f6e848c3ab3593554c6bbfa37af2
parent762f26cf80123a143ceb698a8901512289dc1db8
Bug 1646907 [wpt PR 24247] - SELECT element: Fix a regression on adding multiple selected OPTIONs to a single-selection SELECT, a=testonly

Automatic update from web-platform-tests
SELECT element: Fix a regression on adding multiple selected OPTIONs to a single-selection SELECT

This CL fixes a regression caused by crrev.com/745230.

Bug details:
Suppose that |select.innerHTML = '<option selected>Option1' +
'<option selected>Option2'| runs.

Before crrev.com/745230,

  1. Option1 is appended to the SELECT.
  2. HTMLOptionElement::InsertedInto() and |HTMLSelectElement::
     OptionInserted()| are called for Option1.
  3. SelectOption(Option1) is called.
  4. DeselectItemsWithoutValidation(Option1) is called
  5. Option2 is appended to the SELECT.
  6. HTMLOptionElement::InsertedInto() and |HTMLSelectElement::
     OptionInserted()| are called for Option2.
  7. SelectOption(Option2) is called.
  8. DeselectItemsWithoutValidation(Option2) is called. Option1's
     selected state is cleared.

Since crrev.com/745230,

  1. Option1 is appended to the SELECT.
  2. Option2 is appended to the SELECT.
  3. HTMLSelectElement::ChildrenChanged() and |HTMLSelectElement::
     OptionInserted()| are called for Option1.
  4. SelectOption(Option1) is called.
  5. DeselectItemsWithoutValidation(Option1) is called.  Option2's
     selected state is cleared.
  6. HTMLSelectElement::ChildrenChanged() and |HTMLSelectElement::
     OptionInserted()| are called for Option2.
  7. SelectOption(Option2) is NOT called because Option2's selected
     state was cleared.

Fix:
DeselectItemsWithoutValidation() should not update 'selected' state of
OPTIONs for which OptionInserted() is not called yet. This CL adds a
boolean flag to HTMLOptionElement, it represents whether
OptionInserted() is called or not, and DeselectItemsWithoutValidation()
checks the flag before updating 'selected' state.

Bug: 1095725
Change-Id: If19b28c3edb877549ca498b661647466d03e6d1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2253260
Commit-Queue: Kent Tamura <tkent@chromium.org>
Auto-Submit: Kent Tamura <tkent@chromium.org>
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780174}

--

wpt-commits: e75a8342e588e36a6ab387846a50d077621143b4
wpt-pr: 24247
testing/web-platform/tests/html/semantics/forms/the-select-element/inserted-or-removed.html [new file with mode: 0644]