Files
sousa-gecko/dom/base/test/test_sendSelectionSetEvent_after_reframe.html
T
Emilio Cobos Álvarez 1c763198a6 Bug 2029505 - Don't cache selection in IMEContentObserver. r=m_kato,masayuki
The selection controller might be recreated without editor recreation
itself. This could already realistically happen before bug 2016280 as
far as I can tell.

Differential Revision: https://phabricator.services.mozilla.com/D295508
2026-04-22 09:42:22 +00:00

48 lines
1.6 KiB
HTML

<!doctype html>
<meta charset="utf-8">
<title>Testing nsIDOMWindowUtils.sendSelectionSetEvent works after the editor's selection controller is recreated (bug 2029505)</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script>
"use strict";
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
const flex = document.getElementById("flex");
const input = flex.querySelector("input");
function waitForFlushingIMEContentObserver() {
return new Promise(resolve => requestAnimationFrame(
() => requestAnimationFrame(resolve)
));
}
input.focus();
input.setSelectionRange(input.value.length, input.value.length);
await waitForFlushingIMEContentObserver();
// Force the input to be reframed. This can cause the focused editor's
// selection controller to be recreated while the editor itself survives.
flex.getBoundingClientRect();
flex.style.display = "flex";
flex.getBoundingClientRect();
flex.style.display = "";
flex.getBoundingClientRect();
await waitForFlushingIMEContentObserver();
const ret = windowUtils.sendSelectionSetEvent(
1, 3,
SpecialPowers.Ci.nsIDOMWindowUtils.SELECTION_SET_FLAG_USE_NATIVE_LINE_BREAK
);
ok(ret, "sendSelectionSetEvent should succeed");
is(input.selectionStart, 1,
"selectionStart should be updated after reframe");
is(input.selectionEnd, 4,
"selectionEnd should be updated after reframe");
SimpleTest.finish();
});
</script>
<div id="flex">
<input value="test123">
</div>