test_bug1785739.html (1228B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>nsFind::Find() should initialize the editor</title> 4 <script src="/tests/SimpleTest/SimpleTest.js"></script> 5 <link rel="stylesheet" href="/tests/SimpleTest/test.css"> 6 <input value="1abc1 7 2abc2 8 3abc3 9 4abc4 10 5abc5 11 6abc6 12 7abc7 13 8abc8 14 9abc9" id="input"> 15 <script> 16 SimpleTest.waitForExplicitFinish(); 17 18 // The current window.find() impl does not support text controls, so import the internal component 19 const finder = 20 SpecialPowers 21 .Cc["@mozilla.org/typeaheadfind;1"] 22 .getService(SpecialPowers.Ci.nsITypeAheadFind); 23 24 finder.init(SpecialPowers.wrap(window).docShell); 25 26 async function runTests() { 27 for (let i = 0; i < 9; i++) { 28 let which = i == 0 29 ? SpecialPowers.Ci.nsITypeAheadFind.FIND_FIRST 30 : SpecialPowers.Ci.nsITypeAheadFind.FIND_NEXT; 31 finder.find("abc", false, which, true); 32 // Wait until layout flush as the bug repro needs it 33 await new Promise(requestAnimationFrame); 34 is(input.selectionStart, (i * 19) + 1); 35 } 36 37 SimpleTest.finish(); 38 } 39 window.addEventListener("load", runTests); 40 </script>