test_bug434998.xhtml (2869B)
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=434998 8 --> 9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 10 title="Mozilla Bug 434998" 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=434998" 16 target="_blank">Mozilla Bug 434998</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 // Should not throw 54 var threw = false; 55 try { 56 this.mEditor.contentDocument.execCommand("bold", false, null); 57 } catch (e) { 58 threw = true; 59 } 60 ok(!threw, "The execCommand API should work on <xul:editor>"); 61 progress.removeProgressListener(progressListener, Ci.nsIWebProgress.NOTIFY_ALL); 62 SimpleTest.finish(); 63 } 64 } 65 }, 66 67 68 onProgressChange() 69 { 70 }, 71 72 onLocationChange() 73 { 74 }, 75 76 onStatusChange() 77 { 78 }, 79 80 onSecurityChange() 81 { 82 }, 83 84 onContentBlockingEvent() 85 { 86 }, 87 88 mEditor: null 89 }; 90 91 var progress, progressListener; 92 93 function runTest() { 94 var newEditorElement = document.getElementById("editor"); 95 newEditorElement.makeEditable("html", true); 96 var docShell = newEditorElement.docShell; 97 progress = docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebProgress); 98 progressListener = new EditorContentListener(newEditorElement); 99 progress.addProgressListener(progressListener, Ci.nsIWebProgress.NOTIFY_ALL); 100 newEditorElement.setAttribute("src", "data:text/html,"); 101 } 102 ]]> 103 </script> 104 </window>