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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
var sel = document.getSelection();
var root = document.createElement("root");
document.body.appendChild(root);
function createEditable(tagName, text) {
var node = document.createElement(tagName);
node.contentEditable = true;
node.innerHTML = text;
return node;
}
function test(tagName, compositionText, expected) {
var node = createEditable(tagName, "X");
root.appendChild(node);
var textNode = node.firstChild;
sel.setBaseAndExtent(textNode, 0, textNode, textNode.data.length);
document.execCommand("Delete", false);
textInputController.setMarkedText(compositionText, 0, compositionText.length);
compositingText = node.innerText;
textInputController.unmarkText();
confirmedText = node.innerText;
shouldBe("compositingText", "'" + expected + "'");
shouldBe("confirmedText", "'" + expected + "'");
}
test("div", "AB", "AB");
test("div", "A B", "A B");
test("div", "A B", "A \xA0B");
test("div", "A B", "A \xA0 B");
test("div", "A B", "A \xA0 \xA0B");
test("div", " AB", "\xA0AB");
test("div", " AB", "\xA0 AB");
test("div", " AB", "\xA0 \xA0AB");
test("div", " AB", "\xA0 \xA0 AB");
test("div", " AB", "\xA0 \xA0 \xA0AB");
test("div", " AB", "\xA0 \xA0 \xA0 AB");
test("div", " AB", "\xA0 \xA0 \xA0 \xA0AB");
test("div", "AB ", "AB \xA0");
test("div", "AB ", "AB \xA0\xA0");
test("div", "AB ", "AB \xA0 \xA0");
test("div", "AB ", "AB \xA0 \xA0\xA0");
test("div", "AB ", "AB \xA0 \xA0 \xA0");
test("div", "AB ", "AB \xA0 \xA0 \xA0\xA0");
test("div", " A B ", "\xA0 A \xA0B \xA0");
test("div", "\t\tA\t\tB\t\t", "\xA0 A \xA0B \xA0");
test("div", " ", "\xA0");
test("div", " ", "\xA0\xA0");
test("div", " ", "\xA0 \xA0");
test("pre", "AB", "AB");
test("pre", "A B", "A B");
test("pre", "A B", "A B");
test("pre", "A B", "A B");
test("pre", "A B", "A B");
test("pre", "AB ", "AB ");
test("pre", "AB ", "AB ");
test("pre", "AB ", "AB ");
test("pre", "AB ", "AB ");
test("pre", "AB ", "AB ");
test("pre", "AB ", "AB ");
test("pre", " AB", " AB");
test("pre", " AB", " AB");
test("pre", " AB", " AB");
test("pre", " AB", " AB");
test("pre", " AB", " AB");
test("pre", " AB", " AB");
test("pre", " A B ", " A B ");
test("pre", "\t\tA\t\tB\t\t", "\t\tA\t\tB\t\t");
test("pre", " ", " ");
test("pre", " ", " ");
test("pre", " ", " ");
root.style.display = "none";
</script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
|