editor/libeditor/base/tests/test_bug599983.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.

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

mercurial