test_bug1248186.html (1675B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1248186 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1248186</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="/tests/SimpleTest/EventUtils.js"></script> 11 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 12 <script> 13 SimpleTest.waitForExplicitFinish(); 14 15 SimpleTest.waitForFocus(function () { 16 let editor0 = document.getElementById("editor0"); 17 let editor1 = document.getElementById("editor1"); 18 let editor2 = document.getElementById("editor2"); 19 editor0.focus(); 20 for (let i = 0; i < 5; i++) { 21 synthesizeKey("KEY_ArrowRight"); 22 is(document.activeElement, editor0, "hitting right should not de-focus the editor"); 23 } 24 editor1.focus(); 25 for (let i = 0; i < 5; i++) { 26 synthesizeKey("KEY_ArrowRight"); 27 is(document.activeElement, editor1, "hitting right should not de-focus the editor"); 28 } 29 editor2.focus(); 30 for (let i = 0; i < 8; i++) { 31 synthesizeKey("KEY_ArrowRight"); 32 is(document.activeElement, editor2, "hitting right should not de-focus the editor"); 33 } 34 // make sure we don't get stuck at the end of the "foo" span 35 let selection = getSelection(); 36 is(selection.focusNode.parentElement.id, "bar"); 37 is(selection.focusOffset, 3); 38 39 SimpleTest.finish(); 40 }); 41 </script> 42 </head> 43 <body> 44 <div> 45 <span id="editor0" contenteditable>foo</span> 46 <span></span> 47 </div> 48 <div> 49 <span id="editor1" contenteditable><b>foo</b></span> 50 <span></span> 51 </div> 52 <span id="editor2" contenteditable> 53 <span>foo</span><br> 54 <span id="bar">bar</span></span> 55 </body> 56 </html>