1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/base/tests/test_bug599983.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 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=599983 1.11 +--> 1.12 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.13 + title="Mozilla Bug 599983" onload="runTest()"> 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 1.16 + <script type="application/javascript" 1.17 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.18 + 1.19 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.20 + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=599983" 1.21 + target="_blank">Mozilla Bug 599983</a> 1.22 + <editor xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.23 + id="editor" 1.24 + editortype="html" 1.25 + src="about:blank" /> 1.26 + </body> 1.27 + <script type="application/javascript"> 1.28 + <![CDATA[ 1.29 + 1.30 + SimpleTest.waitForExplicitFinish(); 1.31 + 1.32 + const kAllowInteraction = Components.interfaces.nsIPlaintextEditor 1.33 + .eEditorAllowInteraction; 1.34 + const kMailMask = Components.interfaces.nsIPlaintextEditor.eEditorMailMask; 1.35 + 1.36 + function runTest() { 1.37 + testEditor(false, false); 1.38 + testEditor(false, true); 1.39 + testEditor(true, false); 1.40 + testEditor(true, true); 1.41 + 1.42 + SimpleTest.finish(); 1.43 + } 1.44 + 1.45 + function testEditor(setAllowInteraction, setMailMask) { 1.46 + var desc = " with " + (setAllowInteraction ? "" : "no ") + 1.47 + "eEditorAllowInteraction and " + 1.48 + (setMailMask ? "" : "no ") + "eEditorMailMask"; 1.49 + 1.50 + var editorElem = document.getElementById("editor"); 1.51 + 1.52 + var editorObj = editorElem.getEditor(editorElem.contentWindow); 1.53 + editorObj.flags = (setAllowInteraction ? kAllowInteraction : 0) | 1.54 + (setMailMask ? kMailMask : 0); 1.55 + 1.56 + var editorDoc = editorElem.contentDocument; 1.57 + editorDoc.body.innerHTML = "<p>foo<p>bar"; 1.58 + editorDoc.getSelection().selectAllChildren(editorDoc.body.firstChild); 1.59 + editorDoc.execCommand("bold"); 1.60 + 1.61 + var createsDirty = !setAllowInteraction || setMailMask; 1.62 + 1.63 + (createsDirty ? isnot : is)(editorDoc.querySelector("[_moz_dirty]"), null, 1.64 + "Elements with _moz_dirty" + desc); 1.65 + 1.66 + // Even if we do create _moz_dirty, we should strip it for innerHTML. 1.67 + is(editorDoc.body.innerHTML, "<p><b>foo</b></p><p>bar</p>", 1.68 + "innerHTML" + desc); 1.69 + } 1.70 + 1.71 + ]]> 1.72 + </script> 1.73 +</window>