4 <title>Test for HTMLTextAreaElement.value not returning value including CR
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
11 <div id=
"content" style=
"display: none;">
18 SimpleTest
.waitForExplicitFinish();
19 SimpleTest
.waitForFocus(async () => {
21 * This test should check only the cases with emulating complicated
22 * key events and using XPCOM methods. If you need to add simple textcases,
23 * use testing/web-platform/tests/html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html
26 let textarea
= document
.querySelector("textarea");
28 // This shouldn't occur because widget handles control characters if they
29 // receive native key event, but for backward compatibility as XUL platform,
32 is(textarea
.value
, "\n", "Inputting \\r from keyboard event should be converted to \\n");
35 await
new Promise((resolve
, reject
) => {
36 SimpleTest
.waitForClipboard(
38 () => { SpecialPowers
.clipboardCopyString("ab\r\ncd\ref"); },
41 ok(false, "Clipboard copy failed");
46 synthesizeKey("v", {accelKey
: true});
47 is(textarea
.value
, "ab\ncd\nef", "Pasting \\r from clipboard should be converted to \\n");
50 SpecialPowers
.wrap(textarea
).editor
.insertText("ab\r\ncd\ref");
51 is(textarea
.value
, "ab\ncd\nef", "Inserting \\r with nsIEditor.insertText() should be converted to \\n");
54 synthesizeCompositionChange(
56 { "string": "ab\r\ncd\ref",
59 { "length": 9, "attr": COMPOSITION_ATTR_RAW_CLAUSE
}
62 "caret": { "start": 9, "length": 0 },
64 is(textarea
.value
, "ab\ncd\nef", "Inserting \\r with composition should be converted to \\n");
66 synthesizeComposition({type
: "compositioncommitasis"});
67 is(textarea
.value
, "ab\ncd\nef", "Inserting \\r with committing composition should be converted to \\n");
69 // We don't need to test spellchecker features on Android because of unsupported.
70 if (!navigator
.appVersion
.includes("Android")) {
71 ok(true, "Waiting to run spellchecker...");
72 let inlineSpellchecker
= SpecialPowers
.wrap(textarea
).editor
.getInlineSpellChecker(true);
73 textarea
.value
= "abx ";
74 await
new Promise(resolve
=> {
75 const { onSpellCheck
} = SpecialPowers
.ChromeUtils
.importESModule(
76 "resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs"
78 onSpellCheck(textarea
, () => {
79 SimpleTest
.executeSoon(resolve
);
82 let anonymousDivElement
= SpecialPowers
.wrap(textarea
).editor
.rootElement
;
83 let misspelledWord
= inlineSpellchecker
.getMisspelledWord(anonymousDivElement
.firstChild
, 0);
84 is(misspelledWord
.startOffset
, 0, "Misspelled word start should be 0");
85 is(misspelledWord
.endOffset
, 3, "Misspelled word end should be 3");
86 inlineSpellchecker
.replaceWord(anonymousDivElement
.firstChild
, 0, "ab\r\ncd\ref");
87 is(textarea
.value
, "ab\ncd\nef ", "Inserting \\r from spellchecker should be converted to \\n");