editor/libeditor/text/tests/test_bug600570.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/text/tests/test_bug600570.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,89 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=600570
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 600570</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.13 +  <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
    1.14 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.15 +</head>
    1.16 +<body>
    1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=600570">Mozilla Bug 600570</a>
    1.18 +<p id="display"></p>
    1.19 +<div id="content">
    1.20 +<textarea spellcheck="false">
    1.21 +aaa
    1.22 +[bbb]</textarea>
    1.23 +</div>
    1.24 +<pre id="test">
    1.25 +<script type="application/javascript">
    1.26 +
    1.27 +/** Test for Bug 600570 **/
    1.28 +
    1.29 +// Bug 718316: This test fails on Windows 7 and 8
    1.30 +if (navigator.userAgent.indexOf("Windows NT 6.1") == -1 &&
    1.31 +    navigator.userAgent.indexOf("Windows NT 6.2") == -1) {
    1.32 +
    1.33 +SimpleTest.waitForExplicitFinish();
    1.34 +SimpleTest.waitForFocus(function() {
    1.35 +  var t = document.querySelector("textarea");
    1.36 +  t.value = "[aaa\nbbb]";
    1.37 +  t.focus();
    1.38 +  synthesizeKey("A", {accelKey: true});
    1.39 +
    1.40 +  SimpleTest.executeSoon(function() {
    1.41 +    t.getBoundingClientRect(); // flush layout
    1.42 +    var afterSetValue = snapshotWindow(window);
    1.43 +
    1.44 +    t.value = t.defaultValue;
    1.45 +
    1.46 +    t.selectionStart = 0;
    1.47 +    t.selectionEnd = 4;
    1.48 +    SimpleTest.waitForClipboard("aaa\n",
    1.49 +      function() {
    1.50 +        synthesizeKey("X", {accelKey: true});
    1.51 +      },
    1.52 +      function() {
    1.53 +        t.addEventListener("input", function() {
    1.54 +          t.removeEventListener("input", arguments.callee, false);
    1.55 +
    1.56 +          setTimeout(function() { // Avoid the assertion in bug 649797
    1.57 +            is(t.value, "[aaa\nbbb]", "The value of the textarea should be correct");
    1.58 +            synthesizeKey("A", {accelKey: true});
    1.59 +            is(t.selectionStart, 0, "Select all should set the selection start to the beginning of textarea");
    1.60 +            is(t.selectionEnd, 9, "Select all should set the selection end to the end of textarea");
    1.61 +
    1.62 +            var afterPaste = snapshotWindow(window);
    1.63 +
    1.64 +            var res = compareSnapshots(afterSetValue, afterPaste, true);
    1.65 +            var msg = "Pasting and setting the value directly should result in the same rendering";
    1.66 +            if (!res[0]) {
    1.67 +              msg += "\nRESULT:\n" + res[2] + "\nREFERENCE:\n" + res[1];
    1.68 +            }
    1.69 +            ok(res[0], msg);
    1.70 +
    1.71 +            SimpleTest.finish();
    1.72 +          }, 0);
    1.73 +        }, false);
    1.74 +        synthesizeKey("VK_RIGHT", {});
    1.75 +        synthesizeKey("V", {accelKey: true});
    1.76 +      },
    1.77 +      function() {
    1.78 +        SimpleTest.finish();
    1.79 +      }
    1.80 +    );
    1.81 +  });
    1.82 +});
    1.83 +
    1.84 +}
    1.85 +else {
    1.86 +  ok(true, "Somebody thought it was a great idea to make me type this.");
    1.87 +}
    1.88 +
    1.89 +</script>
    1.90 +</pre>
    1.91 +</body>
    1.92 +</html>

mercurial