Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Char boundary text tests</title>
5 <link rel="stylesheet" type="text/css"
6 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
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>
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
23 var IDs = [ "i1", "d1", "e1", "t1" ];
25 testCharBeforeOffset(IDs, 0, "", 0, 0);
26 testCharBeforeOffset(IDs, 1, "h", 0, 1);
27 testCharBeforeOffset(IDs, 14, "n", 13, 14);
28 testCharBeforeOffset(IDs, 15, "d", 14, 15);
30 testCharAtOffset(IDs, 0, "h", 0, 1);
31 testCharAtOffset(IDs, 1, "e", 1, 2);
32 testCharAtOffset(IDs, 14, "d", 14, 15);
33 testCharAtOffset(IDs, 15, "", 15, 15);
35 testCharAfterOffset(IDs, 0, "e", 1, 2);
36 testCharAfterOffset(IDs, 1, "l", 2, 3);
37 testCharAfterOffset(IDs, 14, "", 15, 15);
38 testCharAfterOffset(IDs, 15, "", 15, 15);
40 //////////////////////////////////////////////////////////////////////////
41 //
42 // __B__r__a__v__e__ __S__i__r__ __ __R__o__b__i__n__ __ __ __r__a__n
43 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
45 IDs = [ "i2", "d2", "e2", "t2" ];
47 testCharBeforeOffset(IDs, 0, "", 0, 0);
48 testCharBeforeOffset(IDs, 1, "B", 0, 1);
49 testCharBeforeOffset(IDs, 6, " ", 5, 6);
50 testCharBeforeOffset(IDs, 10, " ", 9, 10);
51 testCharBeforeOffset(IDs, 11, " ", 10, 11);
52 testCharBeforeOffset(IDs, 17, " ", 16, 17);
53 testCharBeforeOffset(IDs, 19, " ", 18, 19);
55 testCharAtOffset(IDs, 0, "B", 0, 1);
56 testCharAtOffset(IDs, 1, "r", 1, 2);
57 testCharAtOffset(IDs, 5, " ", 5, 6);
58 testCharAtOffset(IDs, 9, " ", 9, 10);
59 testCharAtOffset(IDs, 10, " ", 10, 11);
60 testCharAtOffset(IDs, 17, " ", 17, 18);
62 testCharAfterOffset(IDs, 0, "r", 1, 2);
63 testCharAfterOffset(IDs, 1, "a", 2, 3);
64 testCharAfterOffset(IDs, 4, " ", 5, 6);
65 testCharAfterOffset(IDs, 5, "S", 6, 7);
66 testCharAfterOffset(IDs, 8, " ", 9, 10);
67 testCharAfterOffset(IDs, 9, " ", 10, 11);
68 testCharAfterOffset(IDs, 10, "R", 11, 12);
69 testCharAfterOffset(IDs, 15, " ", 16, 17);
70 testCharAfterOffset(IDs, 16, " ", 17, 18);
71 testCharAfterOffset(IDs, 17, " ", 18, 19);
72 testCharAfterOffset(IDs, 18, "r", 19, 20);
74 //////////////////////////////////////////////////////////////////////////
75 //
76 // __o__n__e__w__o__r__d__\n
77 // 0 1 2 3 4 5 6 7
78 // __\n
79 // 8
80 // __t__w__o__ __w__o__r__d__s__\n
81 // 9 10 11 12 13 14 15 16 17 18
83 IDs = ["d3", "dbr3", "e3", "ebr3", "t3"];
85 testCharBeforeOffset(IDs, 8, "\n", 7, 8);
86 testCharBeforeOffset(IDs, 9, "\n", 8, 9);
87 testCharBeforeOffset(IDs, 10, "t", 9, 10);
89 testCharAtOffset(IDs, 7, "\n", 7, 8);
90 testCharAtOffset(IDs, 8, "\n", 8, 9);
91 testCharAtOffset(IDs, 9, "t", 9, 10);
93 testCharAfterOffset(IDs, 6, "\n", 7, 8);
94 testCharAfterOffset(IDs, 7, "\n", 8, 9);
95 testCharAfterOffset(IDs, 8, "t", 9, 10);
97 SimpleTest.finish();
98 }
100 SimpleTest.waitForExplicitFinish();
101 addA11yLoadEvent(doTest);
102 </script>
103 </head>
104 <body>
106 <p id="display"></p>
107 <div id="content" style="display: none"></div>
108 <pre id="test">
109 </pre>
111 <input id="i1" value="hello my friend"/>
112 <div id="d1">hello my friend</div>
113 <div id="e1" contenteditable="true">hello my friend</div>
114 <textarea id="t1" contenteditable="true">hello my friend</textarea>
116 <input id="i2" value="Brave Sir Robin ran"/>
117 <pre>
118 <div id="d2">Brave Sir Robin ran</div>
119 <div id="e2" contenteditable="true">Brave Sir Robin ran</div>
120 </pre>
121 <textarea id="t2" cols="300">Brave Sir Robin ran</textarea>
123 <pre>
124 <div id="d3">oneword
126 two words
127 </div>
128 <div id="dbr3">oneword<br/><br/>two words<br/></div>
129 <div id="e3" contenteditable="true">oneword
131 two words
132 </div>
133 <div id="ebr3" contenteditable="true">oneword<br/><br/>two words<br/></div>
134 <textarea id="t3" cols="300">oneword
136 two words</textarea>
137 </pre>
139 </body>
140 </html>