Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
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 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=430351 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 430351</title> |
michael@0 | 8 | <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> |
michael@0 | 9 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=430351">Mozilla Bug 430351</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content"> |
michael@0 | 17 | <div id="parent"></div> |
michael@0 | 18 | <div id="editableParent" contenteditable="true"></div> |
michael@0 | 19 | <iframe id="frame"></iframe> |
michael@0 | 20 | <map name="map"><area></map> |
michael@0 | 21 | </div> |
michael@0 | 22 | <pre id="test"> |
michael@0 | 23 | <script class="testbody" type="text/javascript"> |
michael@0 | 24 | |
michael@0 | 25 | /** Test for Bug 430351 **/ |
michael@0 | 26 | |
michael@0 | 27 | var focusableElements = [ |
michael@0 | 28 | "<a tabindex=\"-1\"></a>", |
michael@0 | 29 | "<a tabindex=\"0\"></a>", |
michael@0 | 30 | "<a tabindex=\"0\" disabled></a>", |
michael@0 | 31 | "<a tabindex=\"1\"></a>", |
michael@0 | 32 | "<a contenteditable=\"true\"></a>", |
michael@0 | 33 | |
michael@0 | 34 | "<a href=\"#\"></a>", |
michael@0 | 35 | "<a href=\"#\" tabindex=\"-1\"></a>", |
michael@0 | 36 | "<a href=\"#\" tabindex=\"0\"></a>", |
michael@0 | 37 | "<a href=\"#\" tabindex=\"0\" disabled></a>", |
michael@0 | 38 | "<a href=\"#\" tabindex=\"1\"></a>", |
michael@0 | 39 | "<a href=\"#\" contenteditable=\"true\"></a>", |
michael@0 | 40 | "<a href=\"#\" disabled></a>", |
michael@0 | 41 | |
michael@0 | 42 | "<button></button>", |
michael@0 | 43 | "<button tabindex=\"-1\"></button>", |
michael@0 | 44 | "<button tabindex=\"0\"></button>", |
michael@0 | 45 | "<button tabindex=\"1\"></button>", |
michael@0 | 46 | "<button contenteditable=\"true\"></button>", |
michael@0 | 47 | |
michael@0 | 48 | "<button type=\"reset\"></button>", |
michael@0 | 49 | "<button type=\"reset\" tabindex=\"-1\"></button>", |
michael@0 | 50 | "<button type=\"reset\" tabindex=\"0\"></button>", |
michael@0 | 51 | "<button type=\"reset\" tabindex=\"1\"></button>", |
michael@0 | 52 | "<button type=\"reset\" contenteditable=\"true\"></button>", |
michael@0 | 53 | |
michael@0 | 54 | "<button type=\"submit\"></button>", |
michael@0 | 55 | "<button type=\"submit\" tabindex=\"-1\"></button>", |
michael@0 | 56 | "<button type=\"submit\" tabindex=\"0\"></button>", |
michael@0 | 57 | "<button type=\"submit\" tabindex=\"1\"></button>", |
michael@0 | 58 | "<button type=\"submit\" contenteditable=\"true\"></button>", |
michael@0 | 59 | |
michael@0 | 60 | "<div tabindex=\"-1\"></div>", |
michael@0 | 61 | "<div tabindex=\"0\"></div>", |
michael@0 | 62 | "<div tabindex=\"1\"></div>", |
michael@0 | 63 | "<div contenteditable=\"true\"></div>", |
michael@0 | 64 | "<div tabindex=\"0\" disabled></div>", |
michael@0 | 65 | |
michael@0 | 66 | "<embed>", |
michael@0 | 67 | "<embed tabindex=\"-1\">", |
michael@0 | 68 | "<embed tabindex=\"0\">", |
michael@0 | 69 | "<embed tabindex=\"0\" disabled>", |
michael@0 | 70 | "<embed tabindex=\"1\">", |
michael@0 | 71 | "<embed disabled>", |
michael@0 | 72 | "<embed contenteditable=\"true\">", |
michael@0 | 73 | |
michael@0 | 74 | "<iframe contenteditable=\"true\"></iframe>", |
michael@0 | 75 | |
michael@0 | 76 | "<iframe src=\"about:blank\"></iframe>", |
michael@0 | 77 | "<iframe src=\"about:blank\" disabled></iframe>", |
michael@0 | 78 | "<iframe src=\"about:blank\" tabindex=\"-1\"></iframe>", |
michael@0 | 79 | "<iframe src=\"about:blank\" tabindex=\"0\"></iframe>", |
michael@0 | 80 | "<iframe src=\"about:blank\" tabindex=\"0\" disabled></iframe>", |
michael@0 | 81 | "<iframe src=\"about:blank\" tabindex=\"1\"></iframe>", |
michael@0 | 82 | "<iframe src=\"about:blank\" contenteditable=\"true\"></iframe>", |
michael@0 | 83 | |
michael@0 | 84 | "<iframe></iframe>", |
michael@0 | 85 | "<iframe tabindex=\"-1\"></iframe>", |
michael@0 | 86 | "<iframe tabindex=\"0\"></iframe>", |
michael@0 | 87 | "<iframe tabindex=\"0\" disabled></iframe>", |
michael@0 | 88 | "<iframe tabindex=\"1\"></iframe>", |
michael@0 | 89 | "<iframe disabled></iframe>", |
michael@0 | 90 | |
michael@0 | 91 | "<img tabindex=\"-1\">", |
michael@0 | 92 | "<img tabindex=\"0\">", |
michael@0 | 93 | "<img tabindex=\"0\" disabled>", |
michael@0 | 94 | "<img tabindex=\"1\">", |
michael@0 | 95 | |
michael@0 | 96 | "<input>", |
michael@0 | 97 | "<input tabindex=\"-1\">", |
michael@0 | 98 | "<input tabindex=\"0\">", |
michael@0 | 99 | "<input tabindex=\"1\">", |
michael@0 | 100 | "<input contenteditable=\"true\">", |
michael@0 | 101 | |
michael@0 | 102 | "<input type=\"button\">", |
michael@0 | 103 | "<input type=\"button\" tabindex=\"-1\">", |
michael@0 | 104 | "<input type=\"button\" tabindex=\"0\">", |
michael@0 | 105 | "<input type=\"button\" tabindex=\"1\">", |
michael@0 | 106 | "<input type=\"button\" contenteditable=\"true\">", |
michael@0 | 107 | |
michael@0 | 108 | "<input type=\"checkbox\">", |
michael@0 | 109 | "<input type=\"checkbox\" tabindex=\"-1\">", |
michael@0 | 110 | "<input type=\"checkbox\" tabindex=\"0\">", |
michael@0 | 111 | "<input type=\"checkbox\" tabindex=\"1\">", |
michael@0 | 112 | "<input type=\"checkbox\" contenteditable=\"true\">", |
michael@0 | 113 | |
michael@0 | 114 | "<input type=\"image\">", |
michael@0 | 115 | "<input type=\"image\" tabindex=\"-1\">", |
michael@0 | 116 | "<input type=\"image\" tabindex=\"0\">", |
michael@0 | 117 | "<input type=\"image\" tabindex=\"1\">", |
michael@0 | 118 | "<input type=\"image\" contenteditable=\"true\">", |
michael@0 | 119 | |
michael@0 | 120 | "<input type=\"password\">", |
michael@0 | 121 | "<input type=\"password\" tabindex=\"-1\">", |
michael@0 | 122 | "<input type=\"password\" tabindex=\"0\">", |
michael@0 | 123 | "<input type=\"password\" tabindex=\"1\">", |
michael@0 | 124 | "<input type=\"password\" contenteditable=\"true\">", |
michael@0 | 125 | |
michael@0 | 126 | "<input type=\"radio\">", |
michael@0 | 127 | "<input type=\"radio\" tabindex=\"-1\">", |
michael@0 | 128 | "<input type=\"radio\" tabindex=\"0\">", |
michael@0 | 129 | "<input type=\"radio\" tabindex=\"1\">", |
michael@0 | 130 | "<input type=\"radio\" contenteditable=\"true\">", |
michael@0 | 131 | "<input type=\"radio\" checked>", |
michael@0 | 132 | "<form><input type=\"radio\" name=\"foo\"></form>", |
michael@0 | 133 | |
michael@0 | 134 | "<input type=\"reset\">", |
michael@0 | 135 | "<input type=\"reset\" tabindex=\"-1\">", |
michael@0 | 136 | "<input type=\"reset\" tabindex=\"0\">", |
michael@0 | 137 | "<input type=\"reset\" tabindex=\"1\">", |
michael@0 | 138 | "<input type=\"reset\" contenteditable=\"true\">", |
michael@0 | 139 | |
michael@0 | 140 | "<input type=\"submit\">", |
michael@0 | 141 | "<input type=\"submit\" tabindex=\"-1\">", |
michael@0 | 142 | "<input type=\"submit\" tabindex=\"0\">", |
michael@0 | 143 | "<input type=\"submit\" tabindex=\"1\">", |
michael@0 | 144 | "<input type=\"submit\" contenteditable=\"true\">", |
michael@0 | 145 | |
michael@0 | 146 | "<input type=\"text\">", |
michael@0 | 147 | "<input type=\"text\" tabindex=\"-1\">", |
michael@0 | 148 | "<input type=\"text\" tabindex=\"0\">", |
michael@0 | 149 | "<input type=\"text\" tabindex=\"1\">", |
michael@0 | 150 | "<input type=\"text\" contenteditable=\"true\">", |
michael@0 | 151 | |
michael@0 | 152 | "<input type=\"number\">", |
michael@0 | 153 | "<input type=\"number\" tabindex=\"-1\">", |
michael@0 | 154 | "<input type=\"number\" tabindex=\"0\">", |
michael@0 | 155 | "<input type=\"number\" tabindex=\"1\">", |
michael@0 | 156 | "<input type=\"number\" contenteditable=\"true\">", |
michael@0 | 157 | |
michael@0 | 158 | "<object tabindex=\"-1\"></object>", |
michael@0 | 159 | "<object tabindex=\"0\"></object>", |
michael@0 | 160 | "<object tabindex=\"1\"></object>", |
michael@0 | 161 | "<object contenteditable=\"true\"></object>", |
michael@0 | 162 | |
michael@0 | 163 | "<object classid=\"java:a\"></object>", |
michael@0 | 164 | "<object classid=\"java:a\" tabindex=\"-1\"></object>", |
michael@0 | 165 | "<object classid=\"java:a\" tabindex=\"0\"></object>", |
michael@0 | 166 | "<object classid=\"java:a\" tabindex=\"0\" disabled></object>", |
michael@0 | 167 | "<object classid=\"java:a\" tabindex=\"1\"></object>", |
michael@0 | 168 | "<object classid=\"java:a\" disabled></object>", |
michael@0 | 169 | "<object classid=\"java:a\" contenteditable=\"true\"></object>", |
michael@0 | 170 | |
michael@0 | 171 | "<select></select>", |
michael@0 | 172 | "<select tabindex=\"-1\"></select>", |
michael@0 | 173 | "<select tabindex=\"0\"></select>", |
michael@0 | 174 | "<select tabindex=\"1\"></select>", |
michael@0 | 175 | "<select contenteditable=\"true\"></select>", |
michael@0 | 176 | |
michael@0 | 177 | "<option tabindex='-1'></option>", |
michael@0 | 178 | "<option tabindex='0'></option>", |
michael@0 | 179 | "<option tabindex='1'></option>", |
michael@0 | 180 | "<option contenteditable></option>", |
michael@0 | 181 | |
michael@0 | 182 | "<optgroup tabindex='-1'></optgroup>", |
michael@0 | 183 | "<optgroup tabindex='0'></optgroup>", |
michael@0 | 184 | "<optgroup tabindex='1'></optgroup>", |
michael@0 | 185 | "<optgroup contenteditable></optgroup>" |
michael@0 | 186 | ]; |
michael@0 | 187 | |
michael@0 | 188 | var nonFocusableElements = [ |
michael@0 | 189 | "<a></a>", |
michael@0 | 190 | "<a disabled></a>", |
michael@0 | 191 | |
michael@0 | 192 | "<button tabindex=\"0\" disabled></button>", |
michael@0 | 193 | "<button disabled></button>", |
michael@0 | 194 | |
michael@0 | 195 | "<button type=\"reset\" tabindex=\"0\" disabled></button>", |
michael@0 | 196 | "<button type=\"reset\" disabled></button>", |
michael@0 | 197 | |
michael@0 | 198 | "<button type=\"submit\" tabindex=\"0\" disabled></button>", |
michael@0 | 199 | "<button type=\"submit\" disabled></button>", |
michael@0 | 200 | |
michael@0 | 201 | "<div></div>", |
michael@0 | 202 | "<div disabled></div>", |
michael@0 | 203 | |
michael@0 | 204 | "<img>", |
michael@0 | 205 | "<img disabled>", |
michael@0 | 206 | "<img contenteditable=\"true\">", |
michael@0 | 207 | |
michael@0 | 208 | "<img usemap=\"#map\">", |
michael@0 | 209 | "<img usemap=\"#map\" tabindex=\"-1\">", |
michael@0 | 210 | "<img usemap=\"#map\" tabindex=\"0\">", |
michael@0 | 211 | "<img usemap=\"#map\" tabindex=\"0\" disabled>", |
michael@0 | 212 | "<img usemap=\"#map\" tabindex=\"1\">", |
michael@0 | 213 | "<img usemap=\"#map\" disabled>", |
michael@0 | 214 | "<img usemap=\"#map\" contenteditable=\"true\">", |
michael@0 | 215 | |
michael@0 | 216 | "<input tabindex=\"0\" disabled>", |
michael@0 | 217 | "<input disabled>", |
michael@0 | 218 | |
michael@0 | 219 | "<input type=\"button\" tabindex=\"0\" disabled>", |
michael@0 | 220 | "<input type=\"button\" disabled>", |
michael@0 | 221 | |
michael@0 | 222 | "<input type=\"checkbox\" tabindex=\"0\" disabled>", |
michael@0 | 223 | "<input type=\"checkbox\" disabled>", |
michael@0 | 224 | |
michael@0 | 225 | "<input type=\"file\" tabindex=\"0\" disabled>", |
michael@0 | 226 | "<input type=\"file\" disabled>", |
michael@0 | 227 | |
michael@0 | 228 | "<input type=\"hidden\">", |
michael@0 | 229 | "<input type=\"hidden\" tabindex=\"-1\">", |
michael@0 | 230 | "<input type=\"hidden\" tabindex=\"0\">", |
michael@0 | 231 | "<input type=\"hidden\" tabindex=\"0\" disabled>", |
michael@0 | 232 | "<input type=\"hidden\" tabindex=\"1\">", |
michael@0 | 233 | "<input type=\"hidden\" disabled>", |
michael@0 | 234 | "<input type=\"hidden\" contenteditable=\"true\">", |
michael@0 | 235 | |
michael@0 | 236 | "<input type=\"image\" tabindex=\"0\" disabled>", |
michael@0 | 237 | "<input type=\"image\" disabled>", |
michael@0 | 238 | |
michael@0 | 239 | "<input type=\"password\" tabindex=\"0\" disabled>", |
michael@0 | 240 | "<input type=\"password\" disabled>", |
michael@0 | 241 | |
michael@0 | 242 | "<input type=\"radio\" tabindex=\"0\" disabled>", |
michael@0 | 243 | "<input type=\"radio\" disabled>", |
michael@0 | 244 | |
michael@0 | 245 | "<input type=\"reset\" tabindex=\"0\" disabled>", |
michael@0 | 246 | "<input type=\"reset\" disabled>", |
michael@0 | 247 | |
michael@0 | 248 | "<input type=\"submit\" tabindex=\"0\" disabled>", |
michael@0 | 249 | "<input type=\"submit\" disabled>", |
michael@0 | 250 | |
michael@0 | 251 | "<input type=\"text\" tabindex=\"0\" disabled>", |
michael@0 | 252 | "<input type=\"text\" disabled>", |
michael@0 | 253 | |
michael@0 | 254 | "<object></object>", |
michael@0 | 255 | |
michael@0 | 256 | "<select tabindex=\"0\" disabled></select>", |
michael@0 | 257 | "<select disabled></select>", |
michael@0 | 258 | |
michael@0 | 259 | "<option></option>", |
michael@0 | 260 | "<option tabindex='1' disabled></option>", |
michael@0 | 261 | |
michael@0 | 262 | "<optgroup></optgroup>", |
michael@0 | 263 | "<optgroup tabindex='1' disabled></optgroup>" |
michael@0 | 264 | ]; |
michael@0 | 265 | |
michael@0 | 266 | var focusableInContentEditable = [ |
michael@0 | 267 | "<button></button>", |
michael@0 | 268 | "<button tabindex=\"-1\"></button>", |
michael@0 | 269 | "<button tabindex=\"0\"></button>", |
michael@0 | 270 | "<button tabindex=\"1\"></button>", |
michael@0 | 271 | "<button contenteditable=\"true\"></button>", |
michael@0 | 272 | |
michael@0 | 273 | "<button type=\"reset\"></button>", |
michael@0 | 274 | "<button type=\"reset\" tabindex=\"-1\"></button>", |
michael@0 | 275 | "<button type=\"reset\" tabindex=\"0\"></button>", |
michael@0 | 276 | "<button type=\"reset\" tabindex=\"1\"></button>", |
michael@0 | 277 | "<button type=\"reset\" contenteditable=\"true\"></button>", |
michael@0 | 278 | |
michael@0 | 279 | "<button type=\"submit\"></button>", |
michael@0 | 280 | "<button type=\"submit\" tabindex=\"-1\"></button>", |
michael@0 | 281 | "<button type=\"submit\" tabindex=\"0\"></button>", |
michael@0 | 282 | "<button type=\"submit\" tabindex=\"1\"></button>", |
michael@0 | 283 | "<button type=\"submit\" contenteditable=\"true\"></button>", |
michael@0 | 284 | |
michael@0 | 285 | "<div tabindex=\"-1\"></div>", |
michael@0 | 286 | "<div tabindex=\"0\"></div>", |
michael@0 | 287 | "<div tabindex=\"1\"></div>", |
michael@0 | 288 | "<div tabindex=\"0\" disabled></div>", |
michael@0 | 289 | |
michael@0 | 290 | "<embed>", |
michael@0 | 291 | "<embed tabindex=\"-1\">", |
michael@0 | 292 | "<embed tabindex=\"0\">", |
michael@0 | 293 | "<embed tabindex=\"0\" disabled>", |
michael@0 | 294 | "<embed tabindex=\"1\">", |
michael@0 | 295 | "<embed disabled>", |
michael@0 | 296 | "<embed contenteditable=\"true\">", |
michael@0 | 297 | |
michael@0 | 298 | "<iframe src=\"about:blank\"></iframe>", |
michael@0 | 299 | "<iframe></iframe>", |
michael@0 | 300 | "<iframe src=\"about:blank\" disabled></iframe>", |
michael@0 | 301 | "<iframe disabled></iframe>", |
michael@0 | 302 | "<iframe src=\"about:blank\" tabindex=\"-1\"></iframe>", |
michael@0 | 303 | "<iframe tabindex=\"-1\"></iframe>", |
michael@0 | 304 | "<iframe src=\"about:blank\" tabindex=\"0\"></iframe>", |
michael@0 | 305 | "<iframe tabindex=\"0\"></iframe>", |
michael@0 | 306 | "<iframe src=\"about:blank\" tabindex=\"0\" disabled></iframe>", |
michael@0 | 307 | "<iframe tabindex=\"0\" disabled></iframe>", |
michael@0 | 308 | "<iframe src=\"about:blank\" tabindex=\"1\"></iframe>", |
michael@0 | 309 | "<iframe tabindex=\"1\"></iframe>", |
michael@0 | 310 | "<iframe src=\"about:blank\" contenteditable=\"true\"></iframe>", |
michael@0 | 311 | "<iframe contenteditable=\"true\"></iframe>", |
michael@0 | 312 | |
michael@0 | 313 | "<img tabindex=\"-1\">", |
michael@0 | 314 | "<img tabindex=\"0\">", |
michael@0 | 315 | "<img tabindex=\"0\" disabled>", |
michael@0 | 316 | "<img tabindex=\"1\">", |
michael@0 | 317 | |
michael@0 | 318 | "<input>", |
michael@0 | 319 | "<input tabindex=\"-1\">", |
michael@0 | 320 | "<input tabindex=\"0\">", |
michael@0 | 321 | "<input tabindex=\"1\">", |
michael@0 | 322 | "<input contenteditable=\"true\">", |
michael@0 | 323 | |
michael@0 | 324 | "<input type=\"button\">", |
michael@0 | 325 | "<input type=\"button\" tabindex=\"-1\">", |
michael@0 | 326 | "<input type=\"button\" tabindex=\"0\">", |
michael@0 | 327 | "<input type=\"button\" tabindex=\"1\">", |
michael@0 | 328 | "<input type=\"button\" contenteditable=\"true\">", |
michael@0 | 329 | |
michael@0 | 330 | "<input type=\"file\">", |
michael@0 | 331 | "<input type=\"file\" tabindex=\"-1\">", |
michael@0 | 332 | "<input type=\"file\" tabindex=\"0\">", |
michael@0 | 333 | "<input type=\"file\" tabindex=\"1\">", |
michael@0 | 334 | "<input type=\"file\" contenteditable=\"true\">", |
michael@0 | 335 | |
michael@0 | 336 | "<input type=\"checkbox\">", |
michael@0 | 337 | "<input type=\"checkbox\" tabindex=\"-1\">", |
michael@0 | 338 | "<input type=\"checkbox\" tabindex=\"0\">", |
michael@0 | 339 | "<input type=\"checkbox\" tabindex=\"1\">", |
michael@0 | 340 | "<input type=\"checkbox\" contenteditable=\"true\">", |
michael@0 | 341 | |
michael@0 | 342 | "<input type=\"image\">", |
michael@0 | 343 | "<input type=\"image\" tabindex=\"-1\">", |
michael@0 | 344 | "<input type=\"image\" tabindex=\"0\">", |
michael@0 | 345 | "<input type=\"image\" tabindex=\"1\">", |
michael@0 | 346 | "<input type=\"image\" contenteditable=\"true\">", |
michael@0 | 347 | |
michael@0 | 348 | "<input type=\"password\">", |
michael@0 | 349 | "<input type=\"password\" tabindex=\"-1\">", |
michael@0 | 350 | "<input type=\"password\" tabindex=\"0\">", |
michael@0 | 351 | "<input type=\"password\" tabindex=\"1\">", |
michael@0 | 352 | "<input type=\"password\" contenteditable=\"true\">", |
michael@0 | 353 | |
michael@0 | 354 | "<input type=\"radio\">", |
michael@0 | 355 | "<input type=\"radio\" tabindex=\"-1\">", |
michael@0 | 356 | "<input type=\"radio\" tabindex=\"0\">", |
michael@0 | 357 | "<input type=\"radio\" tabindex=\"1\">", |
michael@0 | 358 | "<input type=\"radio\" contenteditable=\"true\">", |
michael@0 | 359 | "<input type=\"radio\" checked>", |
michael@0 | 360 | "<form><input type=\"radio\" name=\"foo\"></form>", |
michael@0 | 361 | |
michael@0 | 362 | "<input type=\"reset\">", |
michael@0 | 363 | "<input type=\"reset\" tabindex=\"-1\">", |
michael@0 | 364 | "<input type=\"reset\" tabindex=\"0\">", |
michael@0 | 365 | "<input type=\"reset\" tabindex=\"1\">", |
michael@0 | 366 | "<input type=\"reset\" contenteditable=\"true\">", |
michael@0 | 367 | |
michael@0 | 368 | "<input type=\"submit\">", |
michael@0 | 369 | "<input type=\"submit\" tabindex=\"-1\">", |
michael@0 | 370 | "<input type=\"submit\" tabindex=\"0\">", |
michael@0 | 371 | "<input type=\"submit\" tabindex=\"1\">", |
michael@0 | 372 | "<input type=\"submit\" contenteditable=\"true\">", |
michael@0 | 373 | |
michael@0 | 374 | "<input type=\"text\">", |
michael@0 | 375 | "<input type=\"text\" tabindex=\"-1\">", |
michael@0 | 376 | "<input type=\"text\" tabindex=\"0\">", |
michael@0 | 377 | "<input type=\"text\" tabindex=\"1\">", |
michael@0 | 378 | "<input type=\"text\" contenteditable=\"true\">", |
michael@0 | 379 | |
michael@0 | 380 | "<input type=\"number\">", |
michael@0 | 381 | "<input type=\"number\" tabindex=\"-1\">", |
michael@0 | 382 | "<input type=\"number\" tabindex=\"0\">", |
michael@0 | 383 | "<input type=\"number\" tabindex=\"1\">", |
michael@0 | 384 | "<input type=\"number\" contenteditable=\"true\">", |
michael@0 | 385 | |
michael@0 | 386 | "<object tabindex=\"-1\"></object>", |
michael@0 | 387 | "<object tabindex=\"0\"></object>", |
michael@0 | 388 | "<object tabindex=\"1\"></object>", |
michael@0 | 389 | |
michael@0 | 390 | // Disabled doesn't work for <object>. |
michael@0 | 391 | "<object tabindex=\"0\" disabled></object>", |
michael@0 | 392 | "<object disabled></object>", |
michael@0 | 393 | |
michael@0 | 394 | "<select></select>", |
michael@0 | 395 | "<select tabindex=\"-1\"></select>", |
michael@0 | 396 | "<select tabindex=\"0\"></select>", |
michael@0 | 397 | "<select tabindex=\"1\"></select>", |
michael@0 | 398 | "<select contenteditable=\"true\"></select>", |
michael@0 | 399 | |
michael@0 | 400 | "<option tabindex='-1'></option>", |
michael@0 | 401 | "<option tabindex='0'></option>", |
michael@0 | 402 | "<option tabindex='1'></option>", |
michael@0 | 403 | |
michael@0 | 404 | "<optgroup tabindex='-1'></optgroup>", |
michael@0 | 405 | "<optgroup tabindex='0'></optgroup>", |
michael@0 | 406 | "<optgroup tabindex='1'></optgroup>" |
michael@0 | 407 | ]; |
michael@0 | 408 | |
michael@0 | 409 | var focusableInDesignMode = [ |
michael@0 | 410 | "<embed>", |
michael@0 | 411 | "<embed tabindex=\"-1\">", |
michael@0 | 412 | "<embed tabindex=\"0\">", |
michael@0 | 413 | "<embed tabindex=\"0\" disabled>", |
michael@0 | 414 | "<embed tabindex=\"1\">", |
michael@0 | 415 | "<embed disabled>", |
michael@0 | 416 | "<embed contenteditable=\"true\">", |
michael@0 | 417 | |
michael@0 | 418 | "<img tabindex=\"-1\">", |
michael@0 | 419 | "<img tabindex=\"0\">", |
michael@0 | 420 | "<img tabindex=\"0\" disabled>", |
michael@0 | 421 | "<img tabindex=\"1\">", |
michael@0 | 422 | ]; |
michael@0 | 423 | |
michael@0 | 424 | // Can't currently test these, need a plugin. |
michael@0 | 425 | var focusableElementsTODO = [ |
michael@0 | 426 | "<object classid=\"java:a\"></object>", |
michael@0 | 427 | "<object classid=\"java:a\" tabindex=\"-1\"></object>", |
michael@0 | 428 | "<object classid=\"java:a\" tabindex=\"0\"></object>", |
michael@0 | 429 | "<object classid=\"java:a\" tabindex=\"0\" disabled></object>", |
michael@0 | 430 | "<object classid=\"java:a\" tabindex=\"1\"></object>", |
michael@0 | 431 | "<object classid=\"java:a\" disabled></object>", |
michael@0 | 432 | "<object classid=\"java:a\" contenteditable=\"true\"></object>", |
michael@0 | 433 | ]; |
michael@0 | 434 | |
michael@0 | 435 | var serializer = new XMLSerializer(); |
michael@0 | 436 | |
michael@0 | 437 | function testElements(parent, tags, shouldBeFocusable) |
michael@0 | 438 | { |
michael@0 | 439 | var focusable, errorSuffix = ""; |
michael@0 | 440 | if (parent.ownerDocument.designMode == "on") { |
michael@0 | 441 | focusable = focusableInDesignMode; |
michael@0 | 442 | errorSuffix = " in a document with designMode=on"; |
michael@0 | 443 | } |
michael@0 | 444 | else if (parent.contentEditable == "true") { |
michael@0 | 445 | focusable = focusableInContentEditable; |
michael@0 | 446 | } |
michael@0 | 447 | |
michael@0 | 448 | for (var tag of tags) { |
michael@0 | 449 | parent.ownerDocument.body.focus(); |
michael@0 | 450 | |
michael@0 | 451 | if (focusableElementsTODO.indexOf(tag) > -1) { |
michael@0 | 452 | todo_is(parent.ownerDocument.activeElement, parent.firstChild, |
michael@0 | 453 | tag + " should be focusable" + errorSuffix); |
michael@0 | 454 | continue; |
michael@0 | 455 | } |
michael@0 | 456 | |
michael@0 | 457 | parent.innerHTML = tag; |
michael@0 | 458 | |
michael@0 | 459 | // Focus the deepest descendant. |
michael@0 | 460 | var descendant = parent; |
michael@0 | 461 | while ((descendant = descendant.firstChild)) |
michael@0 | 462 | element = descendant; |
michael@0 | 463 | |
michael@0 | 464 | if (element.nodeName == "IFRAME" && element.hasAttribute("src")) |
michael@0 | 465 | var foo = element.contentDocument; |
michael@0 | 466 | |
michael@0 | 467 | element.focus(); |
michael@0 | 468 | |
michael@0 | 469 | var errorPrefix = serializer.serializeToString(element) + " in " + |
michael@0 | 470 | serializer.serializeToString(parent); |
michael@0 | 471 | |
michael@0 | 472 | try { |
michael@0 | 473 | // Make sure activeElement doesn't point to a |
michael@0 | 474 | // native anonymous element. |
michael@0 | 475 | parent.ownerDocument.activeElement.localName; |
michael@0 | 476 | } catch (ex) { |
michael@0 | 477 | ok(false, ex + errorPrefix + errorSuffix); |
michael@0 | 478 | } |
michael@0 | 479 | if (focusable ? focusable.indexOf(tag) > -1 : shouldBeFocusable) { |
michael@0 | 480 | is(parent.ownerDocument.activeElement, element, |
michael@0 | 481 | errorPrefix + " should be focusable" + errorSuffix); |
michael@0 | 482 | } |
michael@0 | 483 | else { |
michael@0 | 484 | isnot(parent.ownerDocument.activeElement, element, |
michael@0 | 485 | errorPrefix + " should not be focusable" + errorSuffix); |
michael@0 | 486 | } |
michael@0 | 487 | |
michael@0 | 488 | parent.innerHTML = ""; |
michael@0 | 489 | } |
michael@0 | 490 | } |
michael@0 | 491 | |
michael@0 | 492 | function test() |
michael@0 | 493 | { |
michael@0 | 494 | var parent = document.getElementById("parent"); |
michael@0 | 495 | var editableParent = document.getElementById("editableParent"); |
michael@0 | 496 | |
michael@0 | 497 | testElements(parent, focusableElements, true); |
michael@0 | 498 | testElements(parent, nonFocusableElements, false); |
michael@0 | 499 | |
michael@0 | 500 | testElements(editableParent, focusableElements, true); |
michael@0 | 501 | testElements(editableParent, nonFocusableElements, false); |
michael@0 | 502 | |
michael@0 | 503 | var frame = document.getElementById("frame"); |
michael@0 | 504 | frame.contentDocument.body.innerHTML = document.getElementById("content").innerHTML; |
michael@0 | 505 | frame.contentDocument.designMode = "on"; |
michael@0 | 506 | parent = frame.contentDocument.getElementById("parent"); |
michael@0 | 507 | editableParent = frame.contentDocument.getElementById("editableParent"); |
michael@0 | 508 | |
michael@0 | 509 | testElements(parent, focusableElements, false); |
michael@0 | 510 | testElements(parent, nonFocusableElements, false); |
michael@0 | 511 | |
michael@0 | 512 | testElements(editableParent, focusableElements, false); |
michael@0 | 513 | testElements(editableParent, nonFocusableElements, false); |
michael@0 | 514 | } |
michael@0 | 515 | |
michael@0 | 516 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 517 | addLoadEvent(test); |
michael@0 | 518 | addLoadEvent(SimpleTest.finish); |
michael@0 | 519 | |
michael@0 | 520 | </script> |
michael@0 | 521 | </pre> |
michael@0 | 522 | </body> |
michael@0 | 523 | </html> |