From aa1ea75c3a23111fca25319b98c0d399c98f922e Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 2 Dec 2020 19:26:49 +0000 Subject: [PATCH] Bug 1679460 - Call Get/SetSelectionRange even when cached r=masayuki No need to special case here as both already use cached selection. This makes it consistent with SetSelectionStart etc. Differential Revision: https://phabricator.services.mozilla.com/D98185 --- dom/html/TextControlState.cpp | 5 ----- .../forms/textfieldselection/select-event.html | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dom/html/TextControlState.cpp b/dom/html/TextControlState.cpp index 031e81ce2306..e178595b4500 100644 --- a/dom/html/TextControlState.cpp +++ b/dom/html/TextControlState.cpp @@ -2212,11 +2212,6 @@ void TextControlState::SetSelectionDirection(const nsAString& aDirection, nsITextControlFrame::SelectionDirection dir = DirectionStringToSelectionDirection(aDirection); - if (IsSelectionCached()) { - GetSelectionProperties().SetDirection(dir); - return; - } - uint32_t start, end; GetSelectionRange(&start, &end, aRv); if (aRv.Failed()) { diff --git a/testing/web-platform/tests/html/semantics/forms/textfieldselection/select-event.html b/testing/web-platform/tests/html/semantics/forms/textfieldselection/select-event.html index 2fb018f82aab..af49024aa2bd 100644 --- a/testing/web-platform/tests/html/semantics/forms/textfieldselection/select-event.html +++ b/testing/web-platform/tests/html/semantics/forms/textfieldselection/select-event.html @@ -43,7 +43,7 @@ const actions = [ }, { label: "setRangeText()", - action: el => el.setRangeText("newmiddle") + action: el => el.setRangeText("newmiddle", el.selectionStart, el.selectionEnd, "select") } ]; @@ -79,6 +79,19 @@ els.forEach((el) => { }, 200); }); }, `${elLabel}: ${action.label} a second time (must not fire select)`); + + promise_test(async t => { + const element = el.cloneNode(true); + + element.onselect = e => { + element.onselect = null; + }; + + action.action(element); + + // step_wait properly timeouts before the whole test collapses + await t.step_wait(() => !element.onselect, "event didn't fire", 200, 10); + }, `${elLabel}: ${action.label} disconnected node`); }); });