5 window
.testRunner
.dumpAsText();
9 return document
.getElementById('inputId');
12 var DEFAULT_LINE_1
= "line\t(1 of 2)\r\nline\t(2 of 2)";
13 var EXPECTED_LINE_1
= "line\t(1 of 2) line\t(2 of 2)";
15 var DEFAULT_LINE_2
= "null\0char";
16 var EXPECTED_LINE_2
= "null\0char";
18 var DEFAULT_LINE_3
= "line with trailing newlines\r\n\r\n";
19 var EXPECTED_LINE_3
= "line with trailing newlines";
21 var TEST_NAME_1
= "Multi-line test";
22 var TEST_NAME_2
= "Null char test";
23 var TEST_NAME_3
= "Trailing newline test";
25 function testMultiline()
27 log(TEST_NAME_1
+ ":");
28 testInputField(DEFAULT_LINE_1
, EXPECTED_LINE_1
);
30 log(TEST_NAME_2
+ ":");
31 testInputField(DEFAULT_LINE_2
, EXPECTED_LINE_2
);
33 log(TEST_NAME_3
+ ":");
34 testInputField(DEFAULT_LINE_3
, EXPECTED_LINE_3
);
37 function testInputField(input_value
, expected
)
39 var input
= getInput();
41 document
.execCommand("SelectAll", false, null);
42 document
.execCommand("InsertText", false, input_value
);
43 var str
= jsEscape(input
.value
);
44 if (str
== jsEscape(expected
))
51 var valueField
= document
.getElementById('console');
52 valueField
.appendChild(document
.createTextNode(str
));
53 valueField
.appendChild(document
.createElement("br"));
68 for (var i
= 0; i
< replacements
.length
; ++i
) {
69 var r
= replacements
[i
];
70 s
= s
.replace(r
[0], r
[1]);
76 .pass { color: green; }
78 .code { font-family: monospace; }
81 <body onload=
"testMultiline()">
82 <h2>Test: This test verifies that text inputs will accept multiple lines of pasted text. You should see three tests
"PASS" below.
</h2>
83 <input id=inputId size=
60 /><br>
84 <span class=code id=console
></span>