editor/composer/test/test_bug434998.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=434998
     8 -->
     9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    10         title="Mozilla Bug 434998" 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=434998"
    18      target="_blank">Mozilla Bug 434998</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           // Should not throw
    61           var threw = false;
    62           try {
    63             this.mEditor.contentDocument.execCommand("bold", false, null);
    64           } catch (e) {
    65             threw = true;
    66           }
    67           ok(!threw, "The execCommand API should work on <xul:editor>");
    68           progress.removeProgressListener(progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
    69           SimpleTest.finish();
    70         }
    71       }
    72     },
    75     onProgressChange : function(aWebProgress, aRequest,
    76                                 aCurSelfProgress, aMaxSelfProgress,
    77                                 aCurTotalProgress, aMaxTotalProgress)
    78     {
    79     },
    81     onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags)
    82     {
    83     },
    85     onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
    86     {
    87     },
    89     onSecurityChange : function(aWebProgress, aRequest, aState)
    90     {
    91     },
    93     mEditor: null
    94   };
    96   var progress, progressListener;
    98   function runTest() {
    99     var newEditorElement = document.getElementById("editor");
   100     newEditorElement.makeEditable("html", true);
   101     var docShell = newEditorElement.boxObject.QueryInterface(Components.interfaces.nsIEditorBoxObject).docShell;
   102     progress = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);
   103     progressListener = new EditorContentListener(newEditorElement);
   104     progress.addProgressListener(progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
   105     newEditorElement.setAttribute("src", "data:text/html,");
   106   }
   107 ]]>
   108 </script>
   109 </window>

mercurial