1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
11 var sel
= document
.getSelection();
12 var root
= document
.createElement("root");
13 document
.body
.appendChild(root
);
16 function createEditable(tagName
, text
) {
17 var node
= document
.createElement(tagName
);
18 node
.contentEditable
= true;
19 node
.innerHTML
= text
;
23 function test(tagName
, compositionText
, expected
) {
24 var node
= createEditable(tagName
, "X");
25 root
.appendChild(node
);
27 var textNode
= node
.firstChild
;
28 sel
.setBaseAndExtent(textNode
, 0, textNode
, textNode
.data
.length
);
29 document
.execCommand("Delete", false);
31 textInputController
.setMarkedText(compositionText
, 0, compositionText
.length
);
32 compositingText
= node
.innerText
;
33 textInputController
.unmarkText();
34 confirmedText
= node
.innerText
;
36 shouldBe("compositingText", "'" + expected
+ "'");
37 shouldBe("confirmedText", "'" + expected
+ "'");
40 test("div", "AB", "AB");
41 test("div", "A B", "A B");
42 test("div", "A B", "A \xA0B");
43 test("div", "A B", "A \xA0 B");
44 test("div", "A B", "A \xA0 \xA0B");
46 test("div", " AB", "\xA0AB");
47 test("div", " AB", "\xA0 AB");
48 test("div", " AB", "\xA0 \xA0AB");
49 test("div", " AB", "\xA0 \xA0 AB");
50 test("div", " AB", "\xA0 \xA0 \xA0AB");
51 test("div", " AB", "\xA0 \xA0 \xA0 AB");
52 test("div", " AB", "\xA0 \xA0 \xA0 \xA0AB");
53 test("div", "AB ", "AB \xA0");
54 test("div", "AB ", "AB \xA0\xA0");
55 test("div", "AB ", "AB \xA0 \xA0");
56 test("div", "AB ", "AB \xA0 \xA0\xA0");
57 test("div", "AB ", "AB \xA0 \xA0 \xA0");
58 test("div", "AB ", "AB \xA0 \xA0 \xA0\xA0");
60 test("div", " A B ", "\xA0 A \xA0B \xA0");
61 test("div", "\t\tA\t\tB\t\t", "\xA0 A \xA0B \xA0");
63 test("div", " ", "\xA0");
64 test("div", " ", "\xA0\xA0");
65 test("div", " ", "\xA0 \xA0");
67 test("pre", "AB", "AB");
68 test("pre", "A B", "A B");
69 test("pre", "A B", "A B");
70 test("pre", "A B", "A B");
71 test("pre", "A B", "A B");
72 test("pre", "AB ", "AB ");
73 test("pre", "AB ", "AB ");
74 test("pre", "AB ", "AB ");
75 test("pre", "AB ", "AB ");
76 test("pre", "AB ", "AB ");
77 test("pre", "AB ", "AB ");
78 test("pre", " AB", " AB");
79 test("pre", " AB", " AB");
80 test("pre", " AB", " AB");
81 test("pre", " AB", " AB");
82 test("pre", " AB", " AB");
83 test("pre", " AB", " AB");
85 test("pre", " A B ", " A B ");
86 test("pre", "\t\tA\t\tB\t\t", "\t\tA\t\tB\t\t");
87 test("pre", " ", " ");
88 test("pre", " ", " ");
89 test("pre", " ", " ");
91 root
.style
.display
= "none";