editor/libeditor/html/tests/test_bug607584.xul

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin"
michael@0 3 type="text/css"?>
michael@0 4 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
michael@0 5 type="text/css"?>
michael@0 6 <!--
michael@0 7 https://bugzilla.mozilla.org/show_bug.cgi?id=607584
michael@0 8 -->
michael@0 9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 10 title="Mozilla Bug 607584" onload="runTest();">
michael@0 11 <script type="application/javascript"
michael@0 12 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
michael@0 13 <script type="application/javascript"
michael@0 14 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
michael@0 15
michael@0 16 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 17 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=607584"
michael@0 18 target="_blank">Mozilla Bug 607584</a>
michael@0 19 <p/>
michael@0 20 <editor xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 21 id="editor"
michael@0 22 type="content-primary"
michael@0 23 editortype="html"
michael@0 24 style="width: 400px; height: 100px; border: thin solid black"/>
michael@0 25 <p/>
michael@0 26 <pre id="test">
michael@0 27 </pre>
michael@0 28 </body>
michael@0 29 <script class="testbody" type="application/javascript">
michael@0 30 <![CDATA[
michael@0 31
michael@0 32 SimpleTest.waitForExplicitFinish();
michael@0 33
michael@0 34 function EditorContentListener(aEditor)
michael@0 35 {
michael@0 36 this.init(aEditor);
michael@0 37 }
michael@0 38
michael@0 39 EditorContentListener.prototype = {
michael@0 40 init : function(aEditor)
michael@0 41 {
michael@0 42 this.mEditor = aEditor;
michael@0 43 },
michael@0 44
michael@0 45 QueryInterface : function(aIID)
michael@0 46 {
michael@0 47 if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
michael@0 48 aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
michael@0 49 aIID.equals(Components.interfaces.nsISupports))
michael@0 50 return this;
michael@0 51 throw Components.results.NS_NOINTERFACE;
michael@0 52 },
michael@0 53
michael@0 54 onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
michael@0 55 {
michael@0 56 if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
michael@0 57 {
michael@0 58 var editor = this.mEditor.getEditor(this.mEditor.contentWindow);
michael@0 59 if (editor) {
michael@0 60 this.mEditor.focus();
michael@0 61 editor instanceof Components.interfaces.nsIHTMLEditor;
michael@0 62 editor.returnInParagraphCreatesNewParagraph = true;
michael@0 63 editor.insertHTML("<p id='foo'>this is a paragraph carrying id 'foo'</p>");
michael@0 64 var p = editor.document.getElementById('foo')
michael@0 65 editor.beginningOfDocument();
michael@0 66 sendKey("return");
michael@0 67 var firstP = p.parentNode.firstElementChild;
michael@0 68 var lastP = p.parentNode.lastElementChild;
michael@0 69 var isOk = firstP.nodeName.toLowerCase() == "p" &&
michael@0 70 firstP.id == "foo" &&
michael@0 71 lastP.id == "";
michael@0 72 ok(isOk, "CR in a paragraph with an ID should not create two paragraphs of same ID");
michael@0 73 progress.removeProgressListener(this);
michael@0 74 SimpleTest.finish();
michael@0 75 }
michael@0 76 }
michael@0 77
michael@0 78 },
michael@0 79
michael@0 80
michael@0 81 onProgressChange : function(aWebProgress, aRequest,
michael@0 82 aCurSelfProgress, aMaxSelfProgress,
michael@0 83 aCurTotalProgress, aMaxTotalProgress)
michael@0 84 {
michael@0 85 },
michael@0 86
michael@0 87 onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags)
michael@0 88 {
michael@0 89 },
michael@0 90
michael@0 91 onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
michael@0 92 {
michael@0 93 },
michael@0 94
michael@0 95 onSecurityChange : function(aWebProgress, aRequest, aState)
michael@0 96 {
michael@0 97 },
michael@0 98
michael@0 99 mEditor: null
michael@0 100 };
michael@0 101
michael@0 102 var progress, progressListener;
michael@0 103
michael@0 104 function runTest() {
michael@0 105 var newEditorElement = document.getElementById("editor");
michael@0 106 newEditorElement.makeEditable("html", true);
michael@0 107 var docShell = newEditorElement.boxObject.QueryInterface(Components.interfaces.nsIEditorBoxObject).docShell;
michael@0 108 progress = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);
michael@0 109 progressListener = new EditorContentListener(newEditorElement);
michael@0 110 progress.addProgressListener(progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
michael@0 111 newEditorElement.setAttribute("src", "data:text/html,");
michael@0 112 }
michael@0 113 ]]>
michael@0 114 </script>
michael@0 115 </window>

mercurial