Closed Bug 1646907 Opened 3 months ago Closed 3 months ago

[wpt-sync] Sync PR 24247 - SELECT element: Fix a regression on adding multiple selected OPTIONs to a single-selection SELECT

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED FIXED
mozilla79
Tracking Status
firefox79 --- fixed

People

(Reporter: mozilla.org, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 24247 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/24247
Details from upstream follow.

Kent Tamura <tkent@chromium.org> wrote:

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/2253260
WPT-Export-Revision: f899b3cc002f1d5243462d484bfd18554072a9e3

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]

CI Results

Ran 0 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 1 tests and 3 subtests

Status Summary

Firefox

OK : 1
PASS: 3

Chrome

OK : 1
PASS: 1
FAIL: 2

Safari

OK : 1
PASS: 2
FAIL: 1

Links

GitHub PR Head
GitHub PR Base

Pushed by wptsync@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/28cfa6865c05
[wpt PR 24247] - SELECT element: Fix a regression on adding multiple selected OPTIONs to a single-selection SELECT, a=testonly
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
You need to log in before you can comment on or make changes to this bug.