test_bug607584.xhtml (3342B)
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=607584 8 --> 9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 10 title="Mozilla Bug 607584" 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=607584" 16 target="_blank">Mozilla Bug 607584</a> 17 <p/> 18 <editor xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 19 id="editor" 20 type="content" 21 primary="true" 22 editortype="html" 23 style="width: 400px; height: 100px; border: thin solid black"/> 24 <p/> 25 <pre id="test"> 26 </pre> 27 </body> 28 <script class="testbody" type="application/javascript"> 29 <![CDATA[ 30 31 SimpleTest.waitForExplicitFinish(); 32 33 function EditorContentListener(aEditor) 34 { 35 this.init(aEditor); 36 } 37 38 EditorContentListener.prototype = { 39 init(aEditor) 40 { 41 this.mEditor = aEditor; 42 }, 43 44 QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener", 45 "nsISupportsWeakReference"]), 46 47 onStateChange(aWebProgress, aRequest, aStateFlags) 48 { 49 if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) 50 { 51 var editor = this.mEditor.getEditor(this.mEditor.contentWindow); 52 if (editor) { 53 this.mEditor.focus(); 54 editor instanceof Ci.nsIHTMLEditor; 55 editor.returnInParagraphCreatesNewParagraph = true; 56 editor.insertHTML("<p id='foo'>this is a paragraph carrying id 'foo'</p>"); 57 var p = editor.document.getElementById('foo') 58 editor.beginningOfDocument(); 59 sendKey("return"); 60 var firstP = p.parentNode.firstElementChild; 61 var lastP = p.parentNode.lastElementChild; 62 var isOk = firstP.nodeName.toLowerCase() == "p" && 63 firstP.id == "foo" && 64 lastP.id == ""; 65 ok(isOk, "CR in a paragraph with an ID should not create two paragraphs of same ID"); 66 progress.removeProgressListener(this); 67 SimpleTest.finish(); 68 } 69 } 70 71 }, 72 73 74 onProgressChange() 75 { 76 }, 77 78 onLocationChange() 79 { 80 }, 81 82 onStatusChange() 83 { 84 }, 85 86 onSecurityChange() 87 { 88 }, 89 90 onContentBlockingEvent() 91 { 92 }, 93 94 mEditor: null 95 }; 96 97 var progress, progressListener; 98 99 function runTest() { 100 var newEditorElement = document.getElementById("editor"); 101 newEditorElement.makeEditable("html", true); 102 var docShell = newEditorElement.docShell; 103 progress = docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebProgress); 104 progressListener = new EditorContentListener(newEditorElement); 105 progress.addProgressListener(progressListener, Ci.nsIWebProgress.NOTIFY_ALL); 106 newEditorElement.setAttribute("src", "data:text/html,"); 107 } 108 ]]> 109 </script> 110 </window>