From d297d27e41b379895a0e3870a1efb133af49419d Mon Sep 17 00:00:00 2001 From: Kent Tamura Date: Wed, 6 Oct 2021 15:55:24 +0000 Subject: [PATCH] Bug 1734150 [wpt PR 31119] - SELECT: Fix deselection behavior on leaving the "multiple" mode, a=testonly Automatic update from web-platform-tests SELECT: Fix deselection behavior on leaving the "multiple" mode If - the SELECT switched from the "multiple" mode, - it had two or more selected OPTIONs, and - last_on_change_option_ was the first selected OPTION, we missed to deselect OPTIONs other than the first one due to the fast path of DeselectItemsWithoutValidation(). This CL clears last_on_change_option_ before calling DeselectItemsWithoutValidation(). Bug: 1245443 Change-Id: Ib9cc4a4770d99ed6782edc73fd8ff1fcb3d8738b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3205138 Auto-Submit: Kent Tamura Reviewed-by: Aleks Totic Commit-Queue: Kent Tamura Cr-Commit-Position: refs/heads/main@{#928412} -- wpt-commits: 45fa9d1d871573fe32ee8f7c159ffbcdadbab341 wpt-pr: 31119 --- .../forms/the-select-element/select-multiple.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/testing/web-platform/tests/html/semantics/forms/the-select-element/select-multiple.html b/testing/web-platform/tests/html/semantics/forms/the-select-element/select-multiple.html index c744144527bf1..e348064151a6a 100644 --- a/testing/web-platform/tests/html/semantics/forms/the-select-element/select-multiple.html +++ b/testing/web-platform/tests/html/semantics/forms/the-select-element/select-multiple.html @@ -33,4 +33,16 @@ assert_true(select.options[1].selected, "second option should be selected."); }, "multiple selected options exist, one set from script"); + +// crbug.com/1245443 +test(() => { + let select = document.createElement("select"); + select.length = 4; + let o1 = select.options.item(1); + select.multiple = true; + select.selectedIndex = 2; + o1.selected = true; + select.multiple = false; + assert_equals(select.selectedOptions.length, 1); +}, "Removing multiple attribute reduces the number of selected OPTIONs to 1");