2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
3 - License, v. 2.0. If a copy of the MPL was not distributed with this
4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
7 https://bugzilla.mozilla.org/show_bug.cgi?id=830600
10 <title>Test for Bug
830600</title>
11 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
12 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
13 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css">
17 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=830600">Mozilla Bug
830600</a>
19 <div id=
"content" style=
"display: none">
21 <input type=
"text" id=
"t1" />
23 <script type=
"application/javascript">
25 /** Test for Bug
830600 **/
26 SimpleTest.waitForExplicitFinish();
27 SimpleTest.waitForFocus(function() {
28 const Ci = SpecialPowers.Ci;
29 function test(str, expected, callback) {
30 var t = document.getElementById(
"t1");
33 var editor = SpecialPowers.wrap(t).editor;
34 editor.newlineHandling = Ci.nsIEditor.eNewlinesStripSurroundingWhitespace;
35 SimpleTest.waitForClipboard(str,
37 SpecialPowers.Cc[
"@mozilla.org/widget/clipboardhelper;1"]
38 .getService(Ci.nsIClipboardHelper)
42 synthesizeKey(
"V", {accelKey: true});
43 is(t.value, expected,
"New line handling works correctly");
48 ok(false,
"Failed to copy the string");
54 function runNextTest() {
56 var currentTest = tests.shift();
57 test(currentTest[
0], currentTest[
1], runNextTest);
84 [
" abc \n def \n ",
" abcdef"],
85 [
"\n abc \n def \n ",
"abcdef"],
86 [
" \n abc \n def ",
"abcdef "],
87 [
" abc\n\ndef ",
" abcdef "],
88 [
" abc \n\n def ",
" abcdef "],