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`);
});
});