editor/libeditor/html/tests/test_bug607584.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial