commit cf0f05533cc23ba918e81ac3669449813799fe9f
☠☠ backed out by ca51e71184bb ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 03 Apr 2012 13:41:04 -0400
changeset 94241 afff429aaf9a8d999577293119167698e0197c20
parent 94240 690cba3bb817a6569decbcf005c6db2bfbae894d
child 94242 ca51e71184bb7e76c9837138f944220af14f2bad
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs741734
milestone14.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
commit cf0f05533cc23ba918e81ac3669449813799fe9f Author: Ehsan Akhgari <ehsan.akhgari@gmail.com> Bug 741734 - Fire the paste event when pasting without formatting; r=roc
editor/libeditor/html/nsHTMLDataTransfer.cpp
editor/libeditor/html/tests/test_bug410986.html
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -1619,16 +1619,19 @@ NS_IMETHODIMP nsHTMLEditor::PasteTransfe
                                 nsnull, 0, true);
 }
 
 // 
 // HTML PasteNoFormatting. Ignore any HTML styles and formating in paste source
 //
 NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(PRInt32 aSelectionType)
 {
+  if (!FireClipboardEvent(NS_PASTE))
+    return NS_OK;
+
   ForceCompositionEnd();
 
   // Get Clipboard Service
   nsresult rv;
   nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the nsITransferable interface for getting the data from the clipboard.
--- a/editor/libeditor/html/tests/test_bug410986.html
+++ b/editor/libeditor/html/tests/test_bug410986.html
@@ -16,46 +16,53 @@ https://bugzilla.mozilla.org/show_bug.cg
   <div id="contents"><span style="color: green;">green text</span></div>
   <div id="editor" contenteditable="true"></div>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 410986 **/
 
+var gPasteEvents = 0;
+document.getElementById("editor").addEventListener("paste", function() {
+  ++gPasteEvents;
+}, false);
+
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
   getSelection().selectAllChildren(document.getElementById("contents"));
   SimpleTest.waitForClipboard("green text",
     function() {
       synthesizeKey("C", {accelKey: true});
     },
     function() {
       var ed = document.getElementById("editor");
       ed.focus();
       if (navigator.platform.indexOf("Mac") >= 0) {
         synthesizeKey("V", {accelKey: true, shiftKey: true, altKey: true});
       } else {
         synthesizeKey("V", {accelKey: true, shiftKey: true});
       }
       is(ed.innerHTML, "green text", "Content should be pasted in plaintext format");
+      is(gPasteEvents, 1, "One paste event must be fired");
 
       ed.innerHTML = "";
       ed.blur();
       getSelection().selectAllChildren(document.getElementById("contents"));
       SimpleTest.waitForClipboard("green text",
         function() {
           synthesizeKey("C", {accelKey: true});
         },
         function() {
           var ed = document.getElementById("editor");
           ed.focus();
           synthesizeKey("V", {accelKey: true});
           isnot(ed.innerHTML.indexOf("<span style=\"color: green;\">green text</span>"), -1,
                 "Content should be pasted in HTML format");
+          is(gPasteEvents, 2, "Two paste events must be fired");
 
           SimpleTest.finish();
         },
         function() {
           ok(false, "Failed to copy the second item to the clipboard");
           SimpleTest.finish();
         }
       );