editor/libeditor/html/tests/test_bug616590.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

     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=616590
     8 -->
     9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    10         title="Mozilla Bug 616590" 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=616590"
    18      target="_blank">Mozilla Bug 616590</a>
    19   <p/>
    20   <editor xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    21           id="editor"
    22           type="content"
    23           editortype="htmlmail"
    24           style="width: 400px; height: 100px;"/>
    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           editor.QueryInterface(Components.interfaces.nsIEditorMailSupport);
    61           editor.insertAsCitedQuotation("<html><body><div contenteditable>foo</div></body></html>", "", true);
    62           document.documentElement.clientWidth;
    63           progress.removeProgressListener(this);
    64           ok(true, "Test complete");
    65           SimpleTest.finish();
    66         }
    67       }
    68     },
    71     onProgressChange : function(aWebProgress, aRequest,
    72                                 aCurSelfProgress, aMaxSelfProgress,
    73                                 aCurTotalProgress, aMaxTotalProgress)
    74     {
    75     },
    77     onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags)
    78     {
    79     },
    81     onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
    82     {
    83     },
    85     onSecurityChange : function(aWebProgress, aRequest, aState)
    86     {
    87     },
    89     mEditor: null
    90   };
    92   var progress, progressListener;
    94   function runTest() {
    95     var editorElement = document.getElementById("editor");
    96     editorElement.makeEditable("htmlmail", true);
    97     var docShell = editorElement.boxObject.QueryInterface(Components.interfaces.nsIEditorBoxObject).docShell;
    98     progress = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);
    99     progressListener = new EditorContentListener(editorElement);
   100     progress.addProgressListener(progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
   101     editorElement.setAttribute("src", "data:text/html,");
   102   }
   103 ]]>
   104 </script>
   105 </window>

mercurial