editor/libeditor/text/tests/test_bug830600.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 5 <html>
michael@0 6 <!--
michael@0 7 https://bugzilla.mozilla.org/show_bug.cgi?id=830600
michael@0 8 -->
michael@0 9 <head>
michael@0 10 <title>Test for Bug 830600</title>
michael@0 11 <script type="application/javascript"
michael@0 12 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 13 <script type="application/javascript"
michael@0 14 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 15 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
michael@0 16 </head>
michael@0 17
michael@0 18 <body>
michael@0 19 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=830600">Mozilla Bug 830600</a>
michael@0 20 <p id="display"></p>
michael@0 21 <div id="content" style="display: none">
michael@0 22 </div>
michael@0 23 <input type="text" id="t1" />
michael@0 24 <pre id="test">
michael@0 25 <script type="application/javascript;version=1.7">
michael@0 26
michael@0 27 /** Test for Bug 830600 **/
michael@0 28 SimpleTest.waitForExplicitFinish();
michael@0 29 SimpleTest.waitForFocus(function() {
michael@0 30 const Ci = Components.interfaces;
michael@0 31 function test(str, expected, callback) {
michael@0 32 var t = document.getElementById("t1");
michael@0 33 t.QueryInterface(Ci.nsIDOMNSEditableElement);
michael@0 34 t.focus();
michael@0 35 t.value = "";
michael@0 36 t.editor.QueryInterface(Ci.nsIPlaintextEditor);
michael@0 37 var origNewlineHandling = t.editor.newlineHandling;
michael@0 38 t.editor.newlineHandling = Ci.nsIPlaintextEditor.eNewlinesStripSurroundingWhitespace
michael@0 39 SimpleTest.waitForClipboard(str,
michael@0 40 function() {
michael@0 41 Components.classes["@mozilla.org/widget/clipboardhelper;1"]
michael@0 42 .getService(Components.interfaces.nsIClipboardHelper)
michael@0 43 .copyString(str, document);
michael@0 44 },
michael@0 45 function() {
michael@0 46 synthesizeKey("V", {accelKey: true});
michael@0 47 is(t.value, expected, "New line handling works correctly");
michael@0 48 t.value = "";
michael@0 49 callback();
michael@0 50 },
michael@0 51 function() {
michael@0 52 ok(false, "Failed to copy the string");
michael@0 53 SimpleTest.finish();
michael@0 54 }
michael@0 55 );
michael@0 56 }
michael@0 57
michael@0 58 function runNextTest() {
michael@0 59 if (tests.length) {
michael@0 60 var currentTest = tests.shift();
michael@0 61 test(currentTest[0], currentTest[1], runNextTest);
michael@0 62 } else {
michael@0 63 SimpleTest.finish();
michael@0 64 }
michael@0 65 }
michael@0 66
michael@0 67 var tests = [
michael@0 68 ["abc", "abc"],
michael@0 69 ["\n", ""],
michael@0 70 [" \n", ""],
michael@0 71 ["\n ", ""],
michael@0 72 [" \n ", ""],
michael@0 73 [" a", " a"],
michael@0 74 ["a ", "a "],
michael@0 75 [" a ", " a "],
michael@0 76 [" \nabc", "abc"],
michael@0 77 ["\n abc", "abc"],
michael@0 78 [" \n abc", "abc"],
michael@0 79 [" \nabc ", "abc "],
michael@0 80 ["\n abc ", "abc "],
michael@0 81 [" \n abc ", "abc "],
michael@0 82 ["abc\n ", "abc"],
michael@0 83 ["abc \n", "abc"],
michael@0 84 ["abc \n ", "abc"],
michael@0 85 [" abc\n ", " abc"],
michael@0 86 [" abc \n", " abc"],
michael@0 87 [" abc \n ", " abc"],
michael@0 88 [" abc \n def \n ", " abcdef"],
michael@0 89 ["\n abc \n def \n ", "abcdef"],
michael@0 90 [" \n abc \n def ", "abcdef "],
michael@0 91 [" abc\n\ndef ", " abcdef "],
michael@0 92 [" abc \n\n def ", " abcdef "],
michael@0 93 ];
michael@0 94
michael@0 95 runNextTest();
michael@0 96 });
michael@0 97
michael@0 98 </script>
michael@0 99 </pre>
michael@0 100 </body>
michael@0 101 </html>

mercurial