Bug 1140617 - Don't clear inline style when pasting image. r=ehsan
authorJorg K <mozilla@jorgk.com>
Wed, 06 May 2015 16:15:00 +0200
changeset 243659 9bbb797f3e28edd6c850f10d55e3e7e189430d2b
parent 243658 90e184f46b30a2e6123d797b911270157aa8b95d
child 243660 2e7ce565cfc4df4aba77fe0de31893c524a96ca7
push id28744
push userkwierso@gmail.com
push dateWed, 13 May 2015 18:12:16 +0000
treeherdermozilla-central@324c3423deaf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1140617
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1140617 - Don't clear inline style when pasting image. r=ehsan
editor/libeditor/nsHTMLDataTransfer.cpp
editor/libeditor/tests/chrome.ini
editor/libeditor/tests/test_bug1140617.xul
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -1088,17 +1088,17 @@ nsresult nsHTMLEditor::InsertObject(cons
     AppendUTF8toUTF16(data64, stuffToPaste);
     stuffToPaste.AppendLiteral("\" alt=\"\" >");
     nsAutoEditBatch beginBatching(this);
     rv = DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(), 
                                  NS_LITERAL_STRING(kFileMime),
                                  aSourceDoc,
                                  aDestinationNode, aDestOffset,
                                  aDoDeleteSelection,
-                                 aIsSafe);
+                                 aIsSafe, false);
   }
 
   return NS_OK;
 }
 
 nsresult
 nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable,
                                      nsIDOMDocument *aSourceDoc,
--- a/editor/libeditor/tests/chrome.ini
+++ b/editor/libeditor/tests/chrome.ini
@@ -20,16 +20,17 @@ skip-if = buildapp == 'mulet'
 [test_bug646194.xul]
 [test_bug780908.xul]
 [test_bug830600.html]
 [test_bug1053048.html]
 [test_bug1100966.html]
 [test_bug1102906.html]
 [test_bug1101392.html]
 [test_bug1140105.html]
+[test_bug1140617.xul]
 [test_bug1154791.html]
 [test_composition_event_created_in_chrome.html]
 [test_contenteditable_text_input_handling.html]
 [test_dragdrop.html]
 skip-if = buildapp == 'mulet'
 [test_htmleditor_keyevent_handling.html]
 [test_selection_move_commands.xul]
 [test_texteditor_keyevent_handling.html]
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_bug1140617.xul
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin"
+                 type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+                 type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1140617
+-->
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        title="Mozilla Bug 1140617" onload="runTest();">
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1140617"
+     target="_blank">Mozilla Bug 1140617</a>
+  <p/>
+  <iframe id="i1" width="200" height="100" src="about:blank" /><br />
+  <img id="i" src="green.png" />
+  <p/>
+  <pre id="test">
+  </pre>
+  </body>
+  <script class="testbody" type="application/javascript">
+  <![CDATA[
+
+function runTest() {
+  function pasteIntoAndCheck() {
+    var e = document.getElementById('i1');
+    var doc = e.contentDocument;
+    doc.designMode = "on";
+    doc.defaultView.focus();
+    var selection = doc.defaultView.getSelection();
+    selection.removeAllRanges();
+    selection.selectAllChildren(doc.body);
+    selection.collapseToEnd();
+
+    doc.execCommand("fontname", false, "Arial");
+    doc.execCommand("bold", false, null);
+    doc.execCommand("insertText", false, "12345");
+    doc.execCommand("paste", false, null);
+    doc.execCommand("insertText", false, "a");
+
+    is(doc.queryCommandValue("fontname"), "Arial", "Arial expected");
+    is(doc.queryCommandState("bold"), true, "Bold expected");
+  }
+
+  function copyToClipBoard() {
+    var tmpNode = document.popupNode;
+    document.popupNode = document.getElementById("i");
+
+    const kCmd = "cmd_copyImageContents";
+    var controller = top.document.commandDispatcher
+                     .getControllerForCommand(kCmd);
+    ok((controller && controller.isCommandEnabled(kCmd)), "have copy command");
+    controller.doCommand(kCmd);
+
+    document.popupNode = tmpNode;
+  }
+
+  copyToClipBoard();
+  pasteIntoAndCheck();
+
+  SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+]]>
+</script>
+</window>