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
This commit is contained in:
Kagami Sascha Rosylight 2020-12-02 19:26:49 +00:00
Родитель a2aec71886
Коммит aa1ea75c3a
2 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -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()) {

Просмотреть файл

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