Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for textupdate handler deactivating EditContext during composition</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<div></div>
<script>
function compositionUpdate(newString) {
synthesizeCompositionChange({
composition: {
string: newString,
clauses: [
{length: newString.length, attr: COMPOSITION_ATTR_RAW_CLAUSE },
]
},
caret: {
start: newString.length,
length: 0,
},
key: {
key: 'a',
}
});
}
const host = document.querySelector('div');
const editContext = new EditContext();
host.editContext = editContext;
add_task(async () => {
await SimpleTest.promiseFocus();
host.focus();
editContext.addEventListener('textupdate', () => {
host.blur();
}, {once: true});
compositionUpdate('x');
is(editContext.text, 'x', 'EditContext.text should have text of composition');
is(document.activeElement, document.body,
'textupdate should be fired and host should be blurred.');
// XXX: Should test compositionend being fired for bug 2048704,
// and textformatupdate once https://github.com/w3c/edit-context/issues/138 is resolved.
});
</script>
</body>
</html>