Bug 728652, null check return value of MozGetDataAt, r=ehsan

This commit is contained in:
Neil Deakin 2012-02-23 15:59:45 -05:00
parent f08f3ca319
commit 74c89efa8b
2 changed files with 15 additions and 5 deletions

View File

@ -117,6 +117,12 @@ function doTest()
// synthesizeDrop(text, textarea, [[{type: "text/plain", data: "Somewhat Longer Text"}]], "copy");
// is(textarea.value, "Somewhat Longer Text", "Drag text/plain onto textarea");
// -------- Test dragging special text type of text/plain to contenteditable
selection.selectAllChildren(text);
synthesizeDrop(text, input, [[{type: "text/x-moz-text-internal", data: "Some Special Text"}]], "copy");
is(input.value, "Some Plain Text", "Drag text/x-moz-text-internal onto input");
// -------- Test dragging regular text of text/plain to contenteditable
selection.selectAllChildren(text);

View File

@ -169,12 +169,16 @@ nsresult nsPlaintextEditor::InsertFromDataTransfer(nsIDOMDataTransfer *aDataTran
nsCOMPtr<nsIVariant> data;
aDataTransfer->MozGetDataAt(NS_LITERAL_STRING("text/plain"), aIndex,
getter_AddRefs(data));
nsAutoString insertText;
data->GetAsAString(insertText);
nsContentUtils::PlatformToDOMLineBreaks(insertText);
if (data) {
nsAutoString insertText;
data->GetAsAString(insertText);
nsContentUtils::PlatformToDOMLineBreaks(insertText);
nsAutoEditBatch beginBatching(this);
return InsertTextAt(insertText, aDestinationNode, aDestOffset, aDoDeleteSelection);
nsAutoEditBatch beginBatching(this);
return InsertTextAt(insertText, aDestinationNode, aDestOffset, aDoDeleteSelection);
}
return NS_OK;
}
nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)