editor/libeditor/html/tests/test_bug780908.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/html/tests/test_bug780908.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,113 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin"
     1.6 +                 type="text/css"?>
     1.7 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     1.8 +                 type="text/css"?>
     1.9 +<!--
    1.10 +https://bugzilla.mozilla.org/show_bug.cgi?id=780908
    1.11 +
    1.12 +adapted from test_bug607584.xul by Kent James <kent@caspia.com>
    1.13 +-->
    1.14 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.15 +        title="Mozilla Bug 780908" onload="runTest();">
    1.16 +  <script type="application/javascript"
    1.17 +    src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    1.18 +  <script type="application/javascript"
    1.19 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.20 +
    1.21 +  <body xmlns="http://www.w3.org/1999/xhtml">
    1.22 +  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=780908"
    1.23 +     target="_blank">Mozilla Bug 780908</a>
    1.24 +  <p/>
    1.25 +  <editor xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.26 +          id="editor"
    1.27 +          type="content-primary"
    1.28 +          editortype="html"
    1.29 +          style="width: 400px; height: 100px; border: thin solid black"/>
    1.30 +  <p/>
    1.31 +  <pre id="test">
    1.32 +  </pre>
    1.33 +  </body>
    1.34 +  <script class="testbody" type="application/javascript">
    1.35 +  <![CDATA[
    1.36 +
    1.37 +  SimpleTest.waitForExplicitFinish();
    1.38 +
    1.39 +  function EditorContentListener(aEditor)
    1.40 +  {
    1.41 +    this.init(aEditor);
    1.42 +  }
    1.43 +  
    1.44 +  EditorContentListener.prototype = {
    1.45 +    init : function(aEditor)
    1.46 +      {
    1.47 +        this.mEditor = aEditor;
    1.48 +      },
    1.49 +  
    1.50 +    QueryInterface : function(aIID)
    1.51 +      {
    1.52 +        if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
    1.53 +            aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
    1.54 +            aIID.equals(Components.interfaces.nsISupports))
    1.55 +          return this;
    1.56 +        throw Components.results.NS_NOINTERFACE;
    1.57 +      },
    1.58 +  
    1.59 +    onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
    1.60 +    {
    1.61 +        if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
    1.62 +        {
    1.63 +          var editor = this.mEditor.getEditor(this.mEditor.contentWindow);
    1.64 +          if (editor) {
    1.65 +              this.mEditor.focus();
    1.66 +              editor instanceof Components.interfaces.nsIHTMLEditor;
    1.67 +              editor.returnInParagraphCreatesNewParagraph = true;
    1.68 +              source = "<html><body><table><head></table></body></html>";
    1.69 +              editor.rebuildDocumentFromSource(source);
    1.70 +              ok(true, "Don't crash when head appears after body");
    1.71 +              source = "<html></head><head><body></body></html>";
    1.72 +              editor.rebuildDocumentFromSource(source);
    1.73 +              ok(true, "Don't crash when /head appears before head");
    1.74 +              SimpleTest.finish();
    1.75 +              progress.removeProgressListener(this);
    1.76 +          }
    1.77 +        }
    1.78 +  
    1.79 +    },
    1.80 +  
    1.81 +  
    1.82 +    onProgressChange : function(aWebProgress, aRequest,
    1.83 +                                aCurSelfProgress, aMaxSelfProgress,
    1.84 +                                aCurTotalProgress, aMaxTotalProgress)
    1.85 +      {
    1.86 +      },
    1.87 +  
    1.88 +    onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags)
    1.89 +      {
    1.90 +      },
    1.91 +  
    1.92 +    onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
    1.93 +      {
    1.94 +      },
    1.95 +  
    1.96 +    onSecurityChange : function(aWebProgress, aRequest, aState)
    1.97 +      {
    1.98 +      },
    1.99 +  
   1.100 +      mEditor: null
   1.101 +  };
   1.102 +
   1.103 +  var progress, progressListener;
   1.104 +
   1.105 +  function runTest() {
   1.106 +    var newEditorElement = document.getElementById("editor");
   1.107 +    newEditorElement.makeEditable("html", true);
   1.108 +    var docShell = newEditorElement.boxObject.QueryInterface(Components.interfaces.nsIEditorBoxObject).docShell;
   1.109 +    progress = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIWebProgress);
   1.110 +    progressListener = new EditorContentListener(newEditorElement);
   1.111 +    progress.addProgressListener(progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
   1.112 +    newEditorElement.setAttribute("src", "data:text/html,");
   1.113 +  }
   1.114 +]]>
   1.115 +</script>
   1.116 +</window>

mercurial