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