Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test that blurring in the compositionend handler doesn't cause a second compositionend to be fired.</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 contenteditable></div>
<script>
'use strict';
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',
}
});
}
function compositionEnd() {
synthesizeComposition({
type: 'compositioncommitasis',
key: {
key: 'b'
}
});
}
add_task(async () => {
await SimpleTest.promiseFocus();
const editor = document.querySelector('div');
let compositionEndCount = 0;
editor.addEventListener('compositionend', () => {
compositionEndCount++;
editor.blur();
});
editor.focus();
compositionUpdate('hello');
compositionEnd();
is(compositionEndCount, 1, 'Should fire only one compositionend event if compositionend handler blurs editor.');
});
</script>
</body>
</html>