1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/text/tests/test_bug830600.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,101 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.6 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.8 +<html> 1.9 +<!-- 1.10 +https://bugzilla.mozilla.org/show_bug.cgi?id=830600 1.11 +--> 1.12 +<head> 1.13 + <title>Test for Bug 830600</title> 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.16 + <script type="application/javascript" 1.17 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.18 + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> 1.19 +</head> 1.20 + 1.21 +<body> 1.22 + <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=830600">Mozilla Bug 830600</a> 1.23 + <p id="display"></p> 1.24 + <div id="content" style="display: none"> 1.25 + </div> 1.26 + <input type="text" id="t1" /> 1.27 + <pre id="test"> 1.28 + <script type="application/javascript;version=1.7"> 1.29 + 1.30 + /** Test for Bug 830600 **/ 1.31 + SimpleTest.waitForExplicitFinish(); 1.32 + SimpleTest.waitForFocus(function() { 1.33 + const Ci = Components.interfaces; 1.34 + function test(str, expected, callback) { 1.35 + var t = document.getElementById("t1"); 1.36 + t.QueryInterface(Ci.nsIDOMNSEditableElement); 1.37 + t.focus(); 1.38 + t.value = ""; 1.39 + t.editor.QueryInterface(Ci.nsIPlaintextEditor); 1.40 + var origNewlineHandling = t.editor.newlineHandling; 1.41 + t.editor.newlineHandling = Ci.nsIPlaintextEditor.eNewlinesStripSurroundingWhitespace 1.42 + SimpleTest.waitForClipboard(str, 1.43 + function() { 1.44 + Components.classes["@mozilla.org/widget/clipboardhelper;1"] 1.45 + .getService(Components.interfaces.nsIClipboardHelper) 1.46 + .copyString(str, document); 1.47 + }, 1.48 + function() { 1.49 + synthesizeKey("V", {accelKey: true}); 1.50 + is(t.value, expected, "New line handling works correctly"); 1.51 + t.value = ""; 1.52 + callback(); 1.53 + }, 1.54 + function() { 1.55 + ok(false, "Failed to copy the string"); 1.56 + SimpleTest.finish(); 1.57 + } 1.58 + ); 1.59 + } 1.60 + 1.61 + function runNextTest() { 1.62 + if (tests.length) { 1.63 + var currentTest = tests.shift(); 1.64 + test(currentTest[0], currentTest[1], runNextTest); 1.65 + } else { 1.66 + SimpleTest.finish(); 1.67 + } 1.68 + } 1.69 + 1.70 + var tests = [ 1.71 + ["abc", "abc"], 1.72 + ["\n", ""], 1.73 + [" \n", ""], 1.74 + ["\n ", ""], 1.75 + [" \n ", ""], 1.76 + [" a", " a"], 1.77 + ["a ", "a "], 1.78 + [" a ", " a "], 1.79 + [" \nabc", "abc"], 1.80 + ["\n abc", "abc"], 1.81 + [" \n abc", "abc"], 1.82 + [" \nabc ", "abc "], 1.83 + ["\n abc ", "abc "], 1.84 + [" \n abc ", "abc "], 1.85 + ["abc\n ", "abc"], 1.86 + ["abc \n", "abc"], 1.87 + ["abc \n ", "abc"], 1.88 + [" abc\n ", " abc"], 1.89 + [" abc \n", " abc"], 1.90 + [" abc \n ", " abc"], 1.91 + [" abc \n def \n ", " abcdef"], 1.92 + ["\n abc \n def \n ", "abcdef"], 1.93 + [" \n abc \n def ", "abcdef "], 1.94 + [" abc\n\ndef ", " abcdef "], 1.95 + [" abc \n\n def ", " abcdef "], 1.96 + ]; 1.97 + 1.98 + runNextTest(); 1.99 + }); 1.100 + 1.101 + </script> 1.102 + </pre> 1.103 +</body> 1.104 +</html>