|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <head> |
|
4 <title>Get text between offsets tests</title> |
|
5 <link rel="stylesheet" type="text/css" |
|
6 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
7 |
|
8 <script type="application/javascript" |
|
9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <script type="application/javascript" |
|
11 src="../common.js"></script> |
|
12 <script type="application/javascript" |
|
13 src="../text.js"></script> |
|
14 |
|
15 <script type="application/javascript"> |
|
16 function doTest() |
|
17 { |
|
18 ////////////////////////////////////////////////////////////////////////// |
|
19 // |
|
20 // __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__ |
|
21 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
22 |
|
23 var IDs = [ "i1", "d1", "e1", "t1" ]; |
|
24 |
|
25 testCharacterCount(IDs, 15); |
|
26 |
|
27 testText(IDs, 0, 1, "h"); |
|
28 testText(IDs, 1, 3, "el"); |
|
29 testText(IDs, 14, 15, "d"); |
|
30 testText(IDs, 0, 15, "hello my friend"); |
|
31 testText(IDs, 0, -1, "hello my friend"); |
|
32 |
|
33 ////////////////////////////////////////////////////////////////////////// |
|
34 // |
|
35 // __B__r__a__v__e__ __S__i__r__ __ __R__o__b__i__n__ __ __ __r__a__n |
|
36 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
37 |
|
38 IDs = [ "i2", "dpre2", "epre2", "t2" ]; |
|
39 |
|
40 testCharacterCount(IDs, 22); |
|
41 |
|
42 testText(IDs, 0, 1, "B"); |
|
43 testText(IDs, 5, 6, " "); |
|
44 testText(IDs, 9, 11, " "); |
|
45 testText(IDs, 16, 19, " "); |
|
46 testText(IDs, 0, 22, "Brave Sir Robin ran"); |
|
47 testText(IDs, 0, -1, "Brave Sir Robin ran"); |
|
48 |
|
49 testCharacterCount(["d2", "e2"], 19); |
|
50 testText(["d2", "e2"], 0, 19, "Brave Sir Robin ran"); |
|
51 |
|
52 ////////////////////////////////////////////////////////////////////////// |
|
53 // |
|
54 // __o__n__e__w__o__r__d__\n |
|
55 // 0 1 2 3 4 5 6 7 |
|
56 // __\n |
|
57 // 8 |
|
58 // __t__w__o__ __w__o__r__d__s__\n |
|
59 // 9 10 11 12 13 14 15 16 17 18 |
|
60 |
|
61 var IDs = ["d3", "dbr3", "e3", "ebr3", "t3"]; |
|
62 |
|
63 testCharacterCount(IDs, 19); |
|
64 |
|
65 testText(IDs, 0, 19, "oneword\n\ntwo words\n"); |
|
66 testText(IDs, 0, -1, "oneword\n\ntwo words\n"); |
|
67 |
|
68 SimpleTest.finish(); |
|
69 } |
|
70 |
|
71 SimpleTest.waitForExplicitFinish(); |
|
72 addA11yLoadEvent(doTest); |
|
73 </script> |
|
74 </head> |
|
75 <body> |
|
76 |
|
77 <p id="display"></p> |
|
78 <div id="content" style="display: none"></div> |
|
79 <pre id="test"> |
|
80 </pre> |
|
81 |
|
82 <input id="i1" value="hello my friend"/> |
|
83 <div id="d1">hello my friend</div> |
|
84 <div id="e1" contenteditable="true">hello my friend</div> |
|
85 <textarea id="t1">hello my friend</textarea> |
|
86 |
|
87 <input id="i2" value="Brave Sir Robin ran"/> |
|
88 <pre><div id="dpre2">Brave Sir Robin ran</div></pre> |
|
89 <pre><div id="epre2" contenteditable="true">Brave Sir Robin ran</div></pre> |
|
90 <textarea id="t2" cols="300">Brave Sir Robin ran</textarea> |
|
91 <div id="d2">Brave Sir Robin ran</div> |
|
92 <div id="e2" contenteditable="true">Brave Sir Robin ran</div> |
|
93 |
|
94 <pre> |
|
95 <div id="d3">oneword |
|
96 |
|
97 two words |
|
98 </div> |
|
99 <div id="dbr3">oneword<br/><br/>two words<br/><br/></div> |
|
100 <div id="e3" contenteditable="true">oneword |
|
101 |
|
102 two words |
|
103 </div> |
|
104 <div id="ebr3" contenteditable="true">oneword<br/><br/>two words<br/><br/></div> |
|
105 <textarea id="t3" cols="300">oneword |
|
106 |
|
107 two words |
|
108 </textarea> |
|
109 </pre> |
|
110 |
|
111 </body> |
|
112 </html> |