1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<!doctype html>
<html>
<head>
<title>Not dispatching DOM "text" event on web apps</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>
<input id="input">
<textarea id="textarea"></textarea>
<div contenteditable id="editor"><p><br></p></div>
<script>
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function doTests() {
for (let editorId of ["input", "textarea", "editor"]) {
let editor = document.getElementById(editorId);
editor.focus();
let fired = false;
function onText() {
fired = true;
}
editor.addEventListener("text", onText);
fired = false;
synthesizeCompositionChange({
composition: {string: "abc",
clauses: [{length: 3, attr: COMPOSITION_ATTR_RAW_CLAUSE}]},
caret: {start: 3, length: 0},
});
ok(!fired, `Starting composition shouldn't fire DOM "text" event in ${editorId}`);
fired = false;
synthesizeComposition({type: "compositioncommitasis", key: {key: "KEY_Enter"}});
ok(!fired, `Committing composition with the latest string shouldn't fire DOM "text" event in ${editorId}`);
fired = false;
synthesizeCompositionChange({
composition: {string: "def",
clauses: [{length: 3, attr: COMPOSITION_ATTR_RAW_CLAUSE}]},
caret: {start: 3, length: 0},
});
ok(!fired, `Restarting composition shouldn't fire DOM "text" event in ${editorId}`);
fired = false;
synthesizeComposition({type: "compositioncommit", data: "", key: {key: "KEY_Escape"}});
ok(!fired, `Committing composition with empty string shouldn't fire DOM "text" event in ${editorId}`);
fired = false;
synthesizeCompositionChange({
composition: {string: "de",
clauses: [{length: 2, attr: COMPOSITION_ATTR_RAW_CLAUSE}]},
caret: {start: 2, length: 0},
});
ok(!fired, `Restarting composition shouldn't fire DOM "text" event in ${editorId}`);
fired = false;
synthesizeComposition({type: "compositioncommit", data: "def", key: {key: "KEY_Escape"}});
ok(!fired, `Committing composition with new string shouldn't fire DOM "text" event in ${editorId}`);
fired = false;
synthesizeComposition({type: "compositioncommit", data: "ghi"});
ok(!fired, `Inserting string shouldn't fire DOM "text" event in ${editorId}`);
editor.removeEventListener("text", onText);
}
SimpleTest.finish();
});
</script>
</body>
</html>
|