tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug599983.xhtml (2334B)


      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=599983
      8 -->
      9 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     10        title="Mozilla Bug 599983" onload="runTest()">
     11  <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
     12  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
     13 
     14  <body xmlns="http://www.w3.org/1999/xhtml">
     15  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=599983"
     16     target="_blank">Mozilla Bug 599983</a>
     17  <editor xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     18          id="editor"
     19          editortype="html"
     20          src="about:blank" />
     21  </body>
     22  <script type="application/javascript">
     23  <![CDATA[
     24 
     25  SimpleTest.waitForExplicitFinish();
     26 
     27  const kAllowInteraction = Ci.nsIEditor.eEditorAllowInteraction;
     28  const kMailMask = Ci.nsIEditor.eEditorMailMask;
     29 
     30  function runTest() {
     31    testEditor(false, false);
     32    testEditor(false, true);
     33    testEditor(true, false);
     34    testEditor(true, true);
     35 
     36    SimpleTest.finish();
     37  }
     38 
     39  function testEditor(setAllowInteraction, setMailMask) {
     40    var desc = " with " + (setAllowInteraction ? "" : "no ") +
     41               "eEditorAllowInteraction and " +
     42               (setMailMask ? "" : "no ") + "eEditorMailMask";
     43 
     44    var editorElem = document.getElementById("editor");
     45 
     46    var editorObj = editorElem.getEditor(editorElem.contentWindow);
     47    editorObj.flags = (setAllowInteraction ? kAllowInteraction : 0) |
     48                      (setMailMask ? kMailMask : 0);
     49 
     50    var editorDoc = editorElem.contentDocument;
     51    editorDoc.body.innerHTML = "<p>foo<p>bar";
     52    editorDoc.getSelection().selectAllChildren(editorDoc.body.firstChild);
     53    editorDoc.execCommand("bold");
     54 
     55    var createsDirty = !setAllowInteraction || setMailMask;
     56 
     57    (createsDirty ? isnot : is)(editorDoc.querySelector("[_moz_dirty]"), null,
     58       "Elements with _moz_dirty" + desc);
     59 
     60    // Even if we do create _moz_dirty, we should strip it for innerHTML.
     61    is(editorDoc.body.innerHTML, "<p><b>foo</b></p><p>bar</p>",
     62       "innerHTML" + desc);
     63  }
     64 
     65  ]]>
     66  </script>
     67 </window>