test_bug1397412.xhtml (2042B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet href="chrome://global/skin" 3 type="text/css"?> 4 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 5 type="text/css"?> 6 <!-- 7 https://bugzilla.mozilla.org/show_bug.cgi?id=1397412 8 --> 9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 10 title="Mozilla Bug 1397412" onload="runTest();"> 11 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 12 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 13 14 <body xmlns="http://www.w3.org/1999/xhtml"> 15 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1397412" 16 target="_blank">Mozilla Bug 1397412</a> 17 <p/> 18 <editor xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 19 id="editor" 20 type="content" 21 editortype="textmail" 22 style="width: 400px; height: 200px;"/> 23 <p/> 24 <pre id="test"> 25 </pre> 26 </body> 27 <script class="testbody" type="application/javascript"> 28 <![CDATA[ 29 function runTest() { 30 var initialHTML1 = "xx<br><br>"; 31 var expectedHTML1 = "xx<br>t"; 32 var initialHTML2 = "xx<br><br>yy<br>"; 33 var expectedHTML2 = "xx<br>t<br>yy<br>"; 34 window.docShell 35 .rootTreeItem 36 .QueryInterface(Ci.nsIDocShell) 37 .appType = Ci.nsIDocShell.APP_TYPE_EDITOR; 38 var e = document.getElementById("editor"); 39 var doc = e.contentDocument; 40 doc.designMode = "on"; 41 doc.defaultView.focus(); 42 var selection = doc.defaultView.getSelection(); 43 var body = doc.body; 44 45 // Test 1. 46 body.innerHTML = initialHTML1; 47 selection.collapse(body, 2); 48 sendString("t"); 49 var actualHTML = body.innerHTML; 50 is(actualHTML, expectedHTML1, "'t' should be inserted after the first <br>"); 51 52 // Test 2. 53 body.innerHTML = initialHTML2; 54 selection.collapse(body, 2); 55 sendString("t"); 56 actualHTML = body.innerHTML; 57 is(actualHTML, expectedHTML2, "'t' should be inserted between <br>s"); 58 59 SimpleTest.finish(); 60 } 61 62 SimpleTest.waitForExplicitFinish(); 63 ]]> 64 </script> 65 </window>