async function copyPlaintext(aText) {
return new Promise(resolve => {
SimpleTest.waitForClipboard(
aText.replace(/\r\n?/g, "\n"),
() => {
let element = document.getElementById("toCopyPlaintext");
element.style.display = "block";
element.focus();
element.value = aText;
synthesizeKey("a", {accelKey: true});
synthesizeKey("c", {accelKey: true});
},
() => {
ok(true, `Succeeded to copy "${aText.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/ /g, "\u00A0")}" to clipboard`);
let element = document.getElementById("toCopyPlaintext");
element.style.display = "none";
resolve();
},
() => {
SimpleTest.finish();
});
});
}
async function doTests() {
// nsIEditor::eNewlinesPasteIntact (0):
// only remove the leading and trailing newlines.
// nsIEditor::eNewlinesPasteToFirst (1) or any other value:
// remove the first newline and all characters following it.
// nsIEditor::eNewlinesReplaceWithSpaces (2, Firefox default):
// replace newlines with spaces.
// nsIEditor::eNewlinesStrip (3):
// remove newlines from the string.
// nsIEditor::eNewlinesReplaceWithCommas (4, Thunderbird default):
// replace newlines with commas.
// nsIEditor::eNewlinesStripSurroundingWhitespace (5):
// collapse newlines and surrounding whitespace characters and
// remove them from the string.
let container = document.getElementById("container");
for (let i = 0; i <= 5; i++) {
await SpecialPowers.pushPrefEnv({"set": [["editor.singleLine.pasteNewlines", i]]});
container.innerHTML = `<input id="input${i}" type="text">`;
let input = document.getElementById(`input${i}`); input.focus();
let editor = SpecialPowers.wrap(input).editor;
for (const kLineBreaker of ["\n", "\r", "\r\n"]) {
for (let kTest of kTests) {
let value = kTest.value.replace(/\n/g, kLineBreaker); input.value = value;
is(editor.rootElement.firstChild.wholeText, kTest.expected[i].setValue,
`Setting value to "${value.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/ /g, "\u00A0")}" when pref is ${i}`); input.value = "";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.