accessible/tests/mochitest/text/test_lineboundary.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 <!DOCTYPE html>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Line boundary getText* functions tests</title>
michael@0 5 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
michael@0 6
michael@0 7 <script type="application/javascript"
michael@0 8 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <script type="application/javascript"
michael@0 10 src="../common.js"></script>
michael@0 11 <script type="application/javascript"
michael@0 12 src="../text.js"></script>
michael@0 13 <script type="application/javascript">
michael@0 14 function doTest()
michael@0 15 {
michael@0 16 //////////////////////////////////////////////////////////////////////////
michael@0 17 // __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__
michael@0 18 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
michael@0 19
michael@0 20 var IDs = [ "input", "div", "editable", "textarea",
michael@0 21 getNode("ta", getNode("ta_cntr").contentDocument) ];
michael@0 22
michael@0 23 testTextBeforeOffset(IDs, BOUNDARY_LINE_START,
michael@0 24 [ [ 0, 15, "", 0, 0 ] ]);
michael@0 25 testTextBeforeOffset(IDs, BOUNDARY_LINE_END,
michael@0 26 [ [ 0, 15, "", 0, 0 ] ]);
michael@0 27
michael@0 28 testTextAtOffset(IDs, BOUNDARY_LINE_START,
michael@0 29 [ [ 0, 15, "hello my friend", 0, 15 ] ]);
michael@0 30 testTextAtOffset(IDs, BOUNDARY_LINE_END,
michael@0 31 [ [ 0, 15, "hello my friend", 0, 15 ] ]);
michael@0 32
michael@0 33 testTextAfterOffset(IDs, BOUNDARY_LINE_START,
michael@0 34 [ [ 0, 15, "", 15, 15 ] ]);
michael@0 35 testTextAfterOffset(IDs, BOUNDARY_LINE_END,
michael@0 36 [ [ 0, 15, "", 15, 15 ] ]);
michael@0 37
michael@0 38 //////////////////////////////////////////////////////////////////////////
michael@0 39 // __o__n__e__w__o__r__d__\n
michael@0 40 // 0 1 2 3 4 5 6 7
michael@0 41 // __\n
michael@0 42 // 8
michael@0 43 // __t__w__o__ __w__o__r__d__s__\n
michael@0 44 // 9 10 11 12 13 14 15 16 17 18
michael@0 45
michael@0 46 IDs = [ "ml_div", "ml_divbr", "ml_editable", "ml_editablebr", "ml_textarea"];
michael@0 47
michael@0 48 testTextBeforeOffset(IDs, BOUNDARY_LINE_START,
michael@0 49 [ [ 0, 7, "", 0, 0 ],
michael@0 50 [ 8, 8, "oneword\n", 0, 8 ],
michael@0 51 [ 9, 18, "\n", 8, 9 ],
michael@0 52 [ 19, 19, "two words\n", 9, 19 ]]);
michael@0 53
michael@0 54 testTextBeforeOffset(IDs, BOUNDARY_LINE_END,
michael@0 55 [ [ 0, 7, "", 0, 0 ],
michael@0 56 [ 8, 8, "oneword", 0, 7 ],
michael@0 57 [ 9, 18, "\n", 7, 8 ],
michael@0 58 [ 19, 19, "\ntwo words", 8, 18 ]]);
michael@0 59
michael@0 60 testTextAtOffset(IDs, BOUNDARY_LINE_START,
michael@0 61 [ [ 0, 7, "oneword\n", 0, 8 ],
michael@0 62 [ 8, 8, "\n", 8, 9 ],
michael@0 63 [ 9, 18, "two words\n", 9, 19 ],
michael@0 64 [ 19, 19, "", 19, 19 ]]);
michael@0 65 testTextAtOffset(IDs, BOUNDARY_LINE_END,
michael@0 66 [ [ 0, 7, "oneword", 0, 7 ],
michael@0 67 [ 8, 8, "\n", 7, 8 ],
michael@0 68 [ 9, 18, "\ntwo words", 8, 18 ],
michael@0 69 [ 19, 19, "\n", 18, 19 ]]);
michael@0 70
michael@0 71 testTextAfterOffset(IDs, BOUNDARY_LINE_START,
michael@0 72 [ [ 0, 7, "\n", 8, 9 ],
michael@0 73 [ 8, 8, "two words\n", 9, 19 ],
michael@0 74 [ 9, 19, "", 19, 19 ]]);
michael@0 75 testTextAfterOffset(IDs, BOUNDARY_LINE_END,
michael@0 76 [ [ 0, 7, "\n", 7, 8 ],
michael@0 77 [ 8, 8, "\ntwo words", 8, 18 ],
michael@0 78 [ 9, 18, "\n", 18, 19 ],
michael@0 79 [ 19, 19, "", 19, 19 ]]);
michael@0 80
michael@0 81 //////////////////////////////////////////////////////////////////////////
michael@0 82 // a * b (* is embedded char for link)
michael@0 83 testTextBeforeOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
michael@0 84 [ [ 0, 5, "", 0, 0 ] ]);
michael@0 85
michael@0 86 testTextBeforeOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
michael@0 87 [ [ 0, 5, "", 0, 0 ] ]);
michael@0 88
michael@0 89 testTextAtOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
michael@0 90 [ [ 0, 5, "a " + kEmbedChar + " c", 0, 5 ] ]);
michael@0 91
michael@0 92 testTextAtOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
michael@0 93 [ [ 0, 5, "a " + kEmbedChar + " c", 0, 5 ] ]);
michael@0 94
michael@0 95 testTextAfterOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
michael@0 96 [ [ 0, 5, "", 5, 5 ] ]);
michael@0 97
michael@0 98 testTextAfterOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
michael@0 99 [ [ 0, 5, "", 5, 5 ] ]);
michael@0 100
michael@0 101 //////////////////////////////////////////////////////////////////////////
michael@0 102 // foo<br> and foo<br><br>
michael@0 103
michael@0 104 testTextAtOffset([ getAccessible("ht_2").firstChild.firstChild ],
michael@0 105 BOUNDARY_LINE_START,
michael@0 106 [ [ 0, 3, "foo", 0, 3 ] ]);
michael@0 107 testTextAtOffset([ getAccessible("ht_3").firstChild.firstChild ],
michael@0 108 BOUNDARY_LINE_START,
michael@0 109 [ [ 0, 3, "foo\n", 0, 4 ], [ 4, 4, "", 4, 4 ] ]);
michael@0 110
michael@0 111 //////////////////////////////////////////////////////////////////////////
michael@0 112 // 'Hello world ' (\n is rendered as space)
michael@0 113
michael@0 114 testTextAtOffset([ "ht_4" ], BOUNDARY_LINE_START,
michael@0 115 [ [ 0, 12, "Hello world ", 0, 12 ] ]);
michael@0 116
michael@0 117 //////////////////////////////////////////////////////////////////////////
michael@0 118 // list items
michael@0 119
michael@0 120 testTextAtOffset([ "li1" ], BOUNDARY_LINE_START,
michael@0 121 [ [ 0, 5, kDiscBulletChar + "Item", 0, 5 ] ]);
michael@0 122 testTextAtOffset([ "li2" ], BOUNDARY_LINE_START,
michael@0 123 [ [ 0, 1, kDiscBulletChar, 0, 1 ] ]);
michael@0 124 testTextAtOffset([ "li3" ], BOUNDARY_LINE_START,
michael@0 125 [ [ 0, 7, kDiscBulletChar + "a long ", 0, 8 ],
michael@0 126 [ 8, 11, "and ", 8, 12 ] ]);
michael@0 127 testTextAtOffset([ "li4" ], BOUNDARY_LINE_START,
michael@0 128 [ [ 0, 6, kDiscBulletChar + "a " + kEmbedChar + " c", 0, 6 ] ]);
michael@0 129 testTextAtOffset([ "ul1" ], BOUNDARY_LINE_START,
michael@0 130 [ [ 0, 0, kEmbedChar, 0, 1 ],
michael@0 131 [ 1, 1, kEmbedChar, 1, 2 ],
michael@0 132 [ 2, 2, kEmbedChar, 2, 3 ],
michael@0 133 [ 3, 4, kEmbedChar, 3, 4 ] ]);
michael@0 134
michael@0 135 //////////////////////////////////////////////////////////////////////////
michael@0 136 // Nested hypertexts
michael@0 137
michael@0 138 testTextAtOffset(["ht_5" ], BOUNDARY_LINE_START,
michael@0 139 [ [ 0, 0, kEmbedChar, 0, 1 ] ]);
michael@0 140
michael@0 141 SimpleTest.finish();
michael@0 142 }
michael@0 143
michael@0 144 SimpleTest.waitForExplicitFinish();
michael@0 145 addA11yLoadEvent(doTest);
michael@0 146 </script>
michael@0 147 </head>
michael@0 148 <body>
michael@0 149
michael@0 150 <a target="_blank"
michael@0 151 title="getTextAtOffset for word boundaries: beginning of a new life"
michael@0 152 href="https://bugzilla.mozilla.org/show_bug.cgi?id=853340">
michael@0 153 Bug 853340
michael@0 154 </a>
michael@0 155 <a target="_blank"
michael@0 156 title="getTextBeforeOffset for word boundaries: evolving"
michael@0 157 href="https://bugzilla.mozilla.org/show_bug.cgi?id=855732">
michael@0 158 Bug 855732
michael@0 159 </a>
michael@0 160 <a target="_blank"
michael@0 161 title=" getTextAfterOffset for line boundary on new rails"
michael@0 162 href="https://bugzilla.mozilla.org/show_bug.cgi?id=882292">
michael@0 163 Bug 882292
michael@0 164 </a>
michael@0 165 <a target="_blank"
michael@0 166 title="getTextAtOffset broken for last object when closing tag is preceded by newline char"
michael@0 167 href="https://bugzilla.mozilla.org/show_bug.cgi?id=947170">
michael@0 168 Bug 947170
michael@0 169 </a>
michael@0 170
michael@0 171 <p id="display"></p>
michael@0 172 <div id="content" style="display: none"></div>
michael@0 173 <pre id="test">
michael@0 174 </pre>
michael@0 175
michael@0 176 <input id="input" value="hello my friend"/>
michael@0 177 <div id="div">hello my friend</div>
michael@0 178 <div id="editable" contenteditable="true">hello my friend</div>
michael@0 179 <textarea id="textarea">hello my friend</textarea>
michael@0 180 <iframe id="ta_cntr"
michael@0 181 src="data:text/html,<html><body><textarea id='ta'>hello my friend</textarea></body></html>"></iframe>
michael@0 182
michael@0 183 <pre>
michael@0 184 <div id="ml_div" style="border-style:outset;">oneword
michael@0 185
michael@0 186 two words
michael@0 187 </div>
michael@0 188 <div id="ml_divbr" style="border-style:outset;">oneword<br/><br/>two words<br/><br/></div>
michael@0 189 <div id="ml_editable" style="border-style:outset;" contenteditable="true">oneword
michael@0 190
michael@0 191 two words
michael@0 192 </div>
michael@0 193 <div id="ml_editablebr" contenteditable="true" style="border-style:outset;">oneword<br/><br/>two words<br/><br/></div>
michael@0 194 <textarea id="ml_textarea" cols="300">oneword
michael@0 195
michael@0 196 two words
michael@0 197 </textarea>
michael@0 198 </pre>
michael@0 199
michael@0 200 <iframe id="ht_1" src="data:text/html,<html><body>a <a href=''>b</a> c</body></html>"></iframe>
michael@0 201
michael@0 202 <iframe id="ht_2" src="data:text/html,<div contentEditable='true'>foo<br/></div>"></iframe>
michael@0 203 <iframe id="ht_3" src="data:text/html,<div contentEditable='true'>foo<br/><br/></div>"></iframe>
michael@0 204
michael@0 205 <p id="ht_4">Hello world
michael@0 206 </p>
michael@0 207
michael@0 208 <ul id="ul1">
michael@0 209 <li id="li1">Item</li>
michael@0 210 <li id="li2"></li>
michael@0 211 <li id="li3" style="width:10ex; font-family:monospace; font-size:10pt;">a long and winding road that lead me to your door</li>
michael@0 212 <li id="li4">a <a href=''>b</a> c</li>
michael@0 213 </ul>
michael@0 214
michael@0 215 <div id="ht_5">
michael@0 216 <div>
michael@0 217 <p>sectiounus</p>
michael@0 218 <p>seciofarus</p>
michael@0 219 </div>
michael@0 220 </div>
michael@0 221
michael@0 222 </body>
michael@0 223 </html>

mercurial