test_bug1186799.html (2243B)
1 <!DOCTYPE> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1186799 5 --> 6 <head> 7 <title>Test for Bug 1186799</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 11 </head> 12 <body> 13 <div id="content"> 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1186799">Mozilla Bug 1186799</a> 15 <p id="display"></p> 16 <div id="content"> 17 <span id="span">span</span> 18 <div id="editor" contenteditable></div> 19 </div> 20 <pre id="test"> 21 <script class="testbody" type="text/javascript"> 22 23 /** Test for Bug 1186799 */ 24 SimpleTest.waitForExplicitFinish(); 25 SimpleTest.waitForFocus(function() { 26 var span = document.getElementById("span"); 27 var editor = document.getElementById("editor"); 28 editor.focus(); 29 30 synthesizeCompositionChange( 31 { "composition": 32 { "string": "\u3042", 33 "clauses": 34 [ 35 { "length": 1, "attr": COMPOSITION_ATTR_RAW_CLAUSE }, 36 ], 37 }, 38 "caret": { "start": 1, "length": 0 }, 39 }); 40 41 ok(isThereIMESelection(), "There should be IME selection"); 42 43 var compositionEnd = false; 44 editor.addEventListener("compositionend", function() { compositionEnd = true; }, true); 45 46 synthesizeMouseAtCenter(span, {}); 47 48 ok(compositionEnd, "composition end should be fired at clicking outside of the editor"); 49 ok(!isThereIMESelection(), "There should be no IME selection"); 50 51 SimpleTest.finish(); 52 }); 53 54 function isThereIMESelection() { 55 var selCon = SpecialPowers.wrap(window). 56 docShell. 57 editingSession. 58 getEditorForWindow(window). 59 selectionController; 60 const kIMESelections = [ 61 SpecialPowers.Ci.nsISelectionController.SELECTION_IME_RAWINPUT, 62 SpecialPowers.Ci.nsISelectionController.SELECTION_IME_SELECTEDRAWTEXT, 63 SpecialPowers.Ci.nsISelectionController.SELECTION_IME_CONVERTEDTEXT, 64 SpecialPowers.Ci.nsISelectionController.SELECTION_IME_SELECTEDCONVERTEDTEXT, 65 ]; 66 for (var i = 0; i < kIMESelections.length; i++) { 67 var sel = selCon.getSelection(kIMESelections[i]); 68 if (sel && sel.rangeCount) { 69 return true; 70 } 71 } 72 return false; 73 } 74 75 </script> 76 </pre> 77 </body> 78 </html>