5 margin: 10; padding: 0;
8 <script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
12 function editingTest() {
13 typeCharacterCommand('1');
14 typeCharacterCommand('2');
16 typeCharacterCommand('3');
18 typeCharacterCommand('4');
19 typeCharacterCommand('5');
20 typeCharacterCommand('6');
23 insertParagraphCommand();
24 typeCharacterCommand('l');
25 typeCharacterCommand('i');
26 typeCharacterCommand('n');
27 typeCharacterCommand('e');
28 typeCharacterCommand(' ');
29 typeCharacterCommand('t');
30 typeCharacterCommand('w');
31 typeCharacterCommand('o');
32 insertLineBreakCommand();
33 insertLineBreakCommand();
34 typeCharacterCommand('a');
35 typeCharacterCommand('n');
36 typeCharacterCommand('d');
37 typeCharacterCommand(' ');
40 typeCharacterCommand('t');
41 typeCharacterCommand('h');
42 typeCharacterCommand('r');
43 typeCharacterCommand('e');
44 typeCharacterCommand('e');
45 typeCharacterCommand(' ');
46 typeCharacterCommand(' ');
47 typeCharacterCommand(' ');
49 insertLineBreakCommand();
54 <title>Attributed String Test</title>
56 <body contenteditable id="root">
58 <div class="editing" id="test"></div>
65 <script type="text/javascript">
67 var console_messages = document.createElement("ol");
71 var item = document.createElement("li");
72 item.appendChild(document.createTextNode(String(message).replace(/0x[0-9a-fA-F]{8}/g, "0xXXXXXXXX")));
73 console_messages.appendChild(item);
76 if (window.testRunner) {
80 testRunner.dumpAsText();
83 log("<pre>" + document.getElementById("wrapper").innerHTML + "</pre>");
84 window.getSelection().collapse(document.body, 0);
86 log("(0, 0): " + textInputController.attributedSubstringFromRange(0, 0));
87 log("(0, 0) length: " + textInputController.attributedSubstringFromRange(0, 0).length());
88 log("(0, 2): " + textInputController.attributedSubstringFromRange(0, 2));
89 log("(0, 2) length: " + textInputController.attributedSubstringFromRange(0, 2).length());
90 log("(1, 2): " + textInputController.attributedSubstringFromRange(1, 2));
91 log("(1, 2) length: " + textInputController.attributedSubstringFromRange(1, 2).length());
92 log("(0, 3): " + textInputController.attributedSubstringFromRange(0, 3));
93 log("(0, 3) length: " + textInputController.attributedSubstringFromRange(0, 3).length());
94 log("(0, 6): " + textInputController.attributedSubstringFromRange(0, 6));
95 log("(0, 6) length: " + textInputController.attributedSubstringFromRange(0, 6).length());
96 log("(0, 7): " + textInputController.attributedSubstringFromRange(0, 7));
97 log("(0, 7) length: " + textInputController.attributedSubstringFromRange(0, 7).length()); // should be 7 characters!
98 log("(0, 31): " + textInputController.attributedSubstringFromRange(0, 31));
99 log("(0, 31) length: " + textInputController.attributedSubstringFromRange(0, 31).length()); // actual length IS 31
100 log("(0, 100): " + textInputController.attributedSubstringFromRange(0, 100));
101 log("(0, 100) length: " + textInputController.attributedSubstringFromRange(0, 100).length()); // should be 31 characters!
102 log("(1, 100): " + textInputController.attributedSubstringFromRange(1, 100));
103 log("(1, 100) length: " + textInputController.attributedSubstringFromRange(1, 100).length()); // should be 30 characters!
104 log("(2, 3): " + textInputController.attributedSubstringFromRange(2, 3));
105 log("(2, 3) length: " + textInputController.attributedSubstringFromRange(2, 3).length());
106 log("(5, 1): " + textInputController.attributedSubstringFromRange(5, 1));
107 log("(5, 1) length: " + textInputController.attributedSubstringFromRange(5, 1).length());
108 log("(5, 2): " + textInputController.attributedSubstringFromRange(5, 2));
109 log("(5, 2) length: " + textInputController.attributedSubstringFromRange(5, 2).length());
110 log("(5, 5): " + textInputController.attributedSubstringFromRange(5, 5));
111 log("(5, 5) length: " + textInputController.attributedSubstringFromRange(5, 5).length());
112 log("(15, 14): " + textInputController.attributedSubstringFromRange(15, 14));
113 log("(15, 14) length: " + textInputController.attributedSubstringFromRange(15, 14).length()); // should be 14 characters!
114 log("(100, 0): " + textInputController.attributedSubstringFromRange(100, 0)); // should be undefined
115 log("(100, 100): " + textInputController.attributedSubstringFromRange(100, 100)); // should be undefined
118 log("Exception: " + ex.description);
121 var console = document.createElement("p");
122 console.appendChild(console_messages);
123 document.body.appendChild(console);
126 document.write("(cannot run interactively)");