Bug 741734 - Fire the paste event when pasting without formatting; r=roc

This commit is contained in:
Ehsan Akhgari 2012-04-03 13:41:04 -04:00
parent 82fdcd0c8e
commit 4625beffc7
2 changed files with 10 additions and 0 deletions

View File

@ -1624,6 +1624,9 @@ NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable)
//
NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(PRInt32 aSelectionType)
{
if (!FireClipboardEvent(NS_PASTE))
return NS_OK;
ForceCompositionEnd();
// Get Clipboard Service

View File

@ -21,6 +21,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410986
/** 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"));
@ -37,6 +42,7 @@ SimpleTest.waitForFocus(function() {
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();
@ -51,6 +57,7 @@ SimpleTest.waitForFocus(function() {
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();
},