Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/editor/libeditor/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 18 kB image not shown  

Quelle  test_bug772796.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/editor/libeditor/tests/test_bug772796.html


<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=772796
-->

<head>
  <meta charset="utf-8">
  <title>Test for Bug 772796</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <style> .pre { white-space: pre } </style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=772796">Mozilla Bug 772796</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>

<div id="editable" contenteditable></div>

<pre id="test">

<script type="application/javascript">
  var tests = [
// FYI: Those tests were ported to join-pre-and-other-block.html
/* 00*/[
  "
test
foobar\nbaz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 01*/[
  "
test
foobar\nbaz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 02*/[
  "
test
foobar\nbaz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 03*/[
  "
test
foo\nbar
"
,
  "
testfoo
bar
"
, // expected
],
/* 04*/[
  "
test
foo\nbar\nbaz
"
,
  "
testfoo
bar\nbaz
"
, // expected
],

// The <br> after the foobar is unfortunate but is behaviour that hasn't changed in bug 772796.
// FYI: Those tests were ported to join-pre-and-other-block.html
/* 05*/[
  "
test
foobar
baz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 06*/[
  "
test
foobar
baz
"
,
  "
testfoobar
baz
"
, // expected
],

// Some tests with block elements.
// FYI: Those tests were ported to join-pre-and-other-block.html
/* 07*/[
  "
test
foobar
baz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 08*/[
  "
test
foobar
baz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 09*/[
  "
test
foobar
baz\nfred
"
,
  "
testfoobar
baz\nfred
"
, // expected
],
/* 10*/[
  "
test
foobar
baz
\nfred
"
,
  "
testfoobar
baz
\nfred
"
, // expected
],
/* 11*/[
  "
test
foo\nbar
baz\nfred
"
,
  "
testfoo
bar
baz\nfred
"
, // expected
],
/* 12*/[
  "
test
foo
bar
baz\nfred
"
,
  "
testfoo
bar
baz\nfred
"
, // expected
],

// Repeating all tests above with the <pre> on a new line.
// We know that backspace doesn't work (bug 1190161). Third argument shows the current outcome.
/* 13-00*/[
  "
test
\n
foobar\nbaz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 14-01*/[
  "
test
\n
foobar\nbaz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 15-02*/[
  "
test
\n
foobar\nbaz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 16-03*/[
  "
test
\n
foo\nbar
"
,
  "
testfoo
bar
"
, // expected
],
/* 17-04*/[
  "
test
\n
foo\nbar\nbaz
"
,
  "
testfoo
bar\nbaz
"
, // expected
],
/* 18-05*/[
  "
test
\n
foobar
baz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 19-06*/[
  "
test
\n
foobar
baz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 20-07*/[
  "
test
\n
foobar
baz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 21-08*/[
  "
test
\n
foobar
baz
"
,
  "
testfoobar
baz
"
, // expected
],
/* 22-09*/[
  "
test
\n
foobar
baz\nfred
"
,
  "
testfoobar
baz\nfred
"
, // expected
],
/* 23-10*/[
  "
test
\n
foobar
baz
\nfred
"
,
  "
testfoobar
baz
\nfred
"
, // expected
],
/* 24-11*/[
  "
test
\n
foo\nbar
baz\nfred
"
,
  "
testfoo
bar
baz\nfred
"
, // expected
],
/* 25-12*/[
  "
test
\n
foo
bar
baz\nfred
"
,
  "
testfoo
bar
baz\nfred
"
, // expected
],

// Some tests without <div>. These exercise the MoveBlock "right in left"
/* 26-00*/[
  "test
foobar\nbaz
"
,
  "testfoobar
baz
"
, // expected
],
/* 27-01*/[
  "test
foobar\nbaz
"
,
  "testfoobar
baz
"
, // expected
],
/* 28-02*/[
  "test
foobar\nbaz
"
,
  "testfoobar
baz
"
, // expected
],
/* 29-03*/[
  "test
foo\nbar
"
,
  "testfoo
bar
"
, // expected
],
/* 30-04*/[
  "test
foo\nbar\nbaz
"
,
  "testfoo
bar\nbaz
"
, // expected
],
/* 31-05*/[
  "test
foobar
baz
"
,
  "testfoobar
baz
"
, // expected
],
/* 32-06*/[
  "test
foobar
baz
"
,
  "testfoobar
baz
"
, // expected
],
/* 33-07*/[
  "test
foobar
baz
"
,
  "testfoobar
baz
"
, // expected
],
/* 34-08*/[
  "test
foobar
baz
"
,
  "testfoobar
baz
"
, // expected
],
/* 35-09*/[
  "test
foobar
baz\nfred
"
,
  "testfoobar
baz\nfred
"
, // expected
],
/* 36-10*/[
  "test
foobar
baz
\nfred
"
,
  "testfoobar
baz
\nfred
"
, // expected
],
/* 37-11*/[
  "test
foo\nbar
baz\nfred
"
,
  "testfoo
bar
baz\nfred
"
, // expected
],
/* 38-12*/[
  "test
foo
bar
baz\nfred
"
,
  "testfoo
bar
baz\nfred
"
, // expected
],

// Some tests with <span class="pre">
// All these exercise MoveBlock "left in right". The "right" is the surrounding "contenteditable" div.
// FYI: Those tests except the cases <span> having <div> were ported to
//      join-different-white-space-style-left-paragraph-and-right-line.html
/* 39-00*/[
  "
test
pre\">foobar\nbaz",
  "
testpre\" style=\"white-space: pre;\">foobar
pre\">baz", // expected
],
/* 40-01*/[
  "
test
pre\">foobar\nbaz",
  "
testpre\" style=\"white-space: pre;\">foobar
pre\">baz", // expected
],
/* 41-02*/[
  "
test
pre\">foobar\nbaz",
  "
testpre\" style=\"white-space: pre;\">foobar
pre\">baz", // expected
],
/* 42-03*/[
  "
test
pre\">foo\nbar",
  "
testpre\" style=\"white-space: pre;\">foo
pre\">bar", // expected
],
/* 43-04*/[
  "
test
pre\">foo\nbar\nbaz",
  "
testpre\" style=\"white-space: pre;\">foo
pre\">bar\nbaz", // expected
],
/* 44-05*/[
  "
test
pre\">foobar
baz
"
,
  "
testpre\" style=\"white-space: pre;\">foobar
pre\">baz", // expected
],
/* 45-06*/[
  "
test
pre\">foobar
baz
"
,
  "
testpre\" style=\"white-space: pre;\">foobar
pre\">baz", // expected
],
/* 46-07*/[
  "
test
pre\">
foobar
baz
"
,
  "
testpre\" style=\"white-space: pre;\">
foobar
pre\">baz", // expected
],
/* 47-08*/[
  "
test
pre\">foobar
baz
"
,
  "
testpre\" style=\"white-space: pre;\">foobar
pre\">
baz
"
, // expected
],
/* 48-09*/[
  "
test
pre\">
foobar
baz\nfred
"
,
  "
testpre\" style=\"white-space: pre;\">
foobar
pre\">baz\nfred", // expected
],
/* 49-10*/[
  "
test
pre\">foobar
baz
\nfred
"
,
  "
testpre\" style=\"white-space: pre;\">foobar
pre\">
baz
\nfred
"
, // expected
],
/* 50-11*/[
  "
test
pre\">
foo\nbar
baz\nfred
"
,
  "
testwhite-space: pre;\">foo
pre\">
bar
baz\nfred
"
, // expected
],
/* 51-12*/[
  "
test
pre\">foo
bar
baz\nfred
"
,
  "
testpre\" style=\"white-space: pre;\">foo
pre\">
bar
baz\nfred
"
, // expected
],

// Some tests with <div class="pre">.
// FYI: Those tests were ported to join-different-white-space-style-paragraphs.html
/* 52-00*/[
  "
test
pre\">foobar\nbaz
"
,
  "
testwhite-space: pre;\">foobar
pre\">baz
"
, // expected
],
/* 53-01*/[
  "
test
pre\">foobar\nbaz
"
,
  "
testwhite-space: pre;\">foobar
pre\">baz
"
, // expected
],
/* 54-02*/[
  "
test
pre\">foobar\nbaz
"
,
  "
testwhite-space: pre;\">foowhite-space: pre;\">bar
pre\">baz
"
, // expected
],
/* 55-03*/[
  "
test
pre\">foo\nbar
"
,
  "
testwhite-space: pre;\">foo
pre\">bar
"
, // expected
],
/* 56-04*/[
  "
test
pre\">foo\nbar\nbaz
"
,
  "
testwhite-space: pre;\">foo
pre\">bar\nbaz
"
, // expected
],
/* 57-05*/[
  "
test
pre\">foobar
baz
"
,
  "
testwhite-space: pre;\">foobar
pre\">baz
"
, // expected
],
/* 58-06*/[
  "
test
pre\">foobar
baz
"
,
  "
testwhite-space: pre;\">foobar
pre\">baz
"
, // expected
],
/* 59-07*/[
  "
test
pre\">
foobar
baz
"
,
  "
testwhite-space: pre;\">foobar
pre\">baz
"
, // expected
],
/* 60-08*/[
  "
test
pre\">foobar
baz
"
,
  "
testwhite-space: pre;\">foobar
pre\">
baz
"
, // expected
],
/* 61-09*/[
  "
test
pre\">
foobar
baz\nfred
"
,
  "
testwhite-space: pre;\">foobar
pre\">baz\nfred
"
, // expected
],
/* 62-10*/[
  "
test
pre\">foobar
baz
\nfred
"
,
  "
testwhite-space: pre;\">foobar
pre\">
baz
\nfred
"
, // expected
],
/* 63-11*/[
  "
test
pre\">
foo\nbar
baz\nfred
"
,
  "
testwhite-space: pre;\">foo
pre\">
bar
baz\nfred
"
, // expected
],
/* 64-12*/[
  "
test
pre\">foo
bar
baz\nfred
"
,
  "
testwhite-space: pre;\">foo
pre\">
bar
baz\nfred
"
, // expected
],

// Some tests with lists. These exercise the MoveBlock "left in right".
/* 65*/[
  "
  • test
  • foobar\nbaz
"
,
  "
  • testfoobar
  • baz
"
, // expected
],
/* 66*/[
  "
  • test
  • foobar\nbaz
"
,
  "
  • testfoobar
  • baz
"
, // expected
],
/* 67*/[
  "
  • test
  • foobar\nbaz
"
,
  "
  • testfoobar
  • baz
"
, // expected
],
/* 68*/[
  "
  • test
  • foo\nbar
"
,
  "
  • testfoo
  • bar
"
, // expected
],
/* 69*/[
  "
  • test
  • foo\nbar\nbaz
"
,
  "
  • testfoo
  • bar\nbaz
"
, // expected
],

// Last not least, some simple edge case tests.
// FYI: Those tests were ported to join-pre-and-other-block.html
/* 70*/[
  "
test
foobar\n
baz"
,
  "
testfoobar
baz"
, // expected
],
/* 71*/[
  "
test
\nfoo\nbar
"
,
  "
testfoo
bar
"
, // expected
],
/* 72*/[
  "
test
\n\nfoo\nbar
"
,
  "
test
foo\nbar
"
, // expected
],
];

    /** Test for Bug 772796 **/

    SimpleTest.waitForExplicitFinish();
    SimpleTest.waitForFocus(function() {
      var sel = window.getSelection();
      var theEdit = document.getElementById("editable");
      var testName;
      var theDiv;

      for (let i = 0; i < tests.length; i++) {
        testName = "test" + i.toString();

        /* Set up the selection. */
        theEdit.innerHTML = "
" + testName + "\">" + tests[i][0] + "
"
;
        theDiv = document.getElementById(testName);
        theDiv.focus();
        sel.collapse(theDiv, 0);
        synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */

        function normalizeStyeAttributeValues(aElement) {
          for (const element of Array.from(
            aElement.querySelectorAll("[style]")
          )) {
            element.setAttribute(
              "style",
              element
                .getAttribute("style")
                // Random spacing differences
                .replace(/$/, ";")
                .replace(/;;$/, ";")
                // Gecko likes "transparent"
                .replace(/transparent/g, "rgba(0, 0, 0, 0)")
                // WebKit likes to look overly precise
                .replace(/, 0.496094\)/g, ", 0.5)")
                // Gecko converts anything with full alpha to "transparent" which
                // then becomes "rgba(0, 0, 0, 0)", so we have to make other
                // browsers match
                .replace(/rgba\([0-9]+, [0-9]+, [0-9]+, 0\)/g, "rgba(0, 0, 0, 0)")
            );
          }
        }

        let todoCount = 0;
        /** First round: Forward delete. **/
        synthesizeKey("KEY_Delete");
        normalizeStyeAttributeValues(theDiv);
        if (tests[i].length == 2 || theDiv.innerHTML == tests[i][1]) {
          is(theDiv.innerHTML, tests[i][1], "delete(collapsed): inner HTML for " + testName);
        } else {
          todoCount++;
          todo_is(theDiv.innerHTML, tests[i][1], "delete(should be): inner HTML for " + testName);
          is(theDiv.innerHTML, tests[i][2], "delete(currently is): inner HTML for " + testName);
        }

        /* Set up the selection. */
        theEdit.innerHTML = "
" + testName + "\">" + tests[i][0] + "
"
;
        theDiv = document.getElementById(testName);
        theDiv.focus();
        sel.collapse(theDiv, 0);
        synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */

        /** Second round: Backspace. **/
        synthesizeKey("KEY_ArrowRight");
        synthesizeKey("KEY_Backspace");
        normalizeStyeAttributeValues(theDiv);
        if (tests[i].length == 2 || theDiv.innerHTML == tests[i][1]) {
          is(theDiv.innerHTML, tests[i][1], "backspace: inner HTML for " + testName);
        } else {
          todoCount++;
          todo_is(theDiv.innerHTML, tests[i][1], "backspace(should be): inner HTML for " + testName);
          is(theDiv.innerHTML, tests[i][2], "backspace(currently is): inner HTML for " + testName);
        }

        /* Set up the selection. */
        theEdit.innerHTML = "
" + testName + "\">" + tests[i][0] + "
"
;
        theDiv = document.getElementById(testName);
        theDiv.focus();
        sel.collapse(theDiv, 0);
        synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */

        /** Third round: Delete with non-collapsed selection. **/
        if (i == 72) {
          if (tests[i].length == 3) {
            ok(!!todoCount, `All tests unexpectedly passed in ${testName}`);
          }
          // This test doesn't work, since we can'select only one newline using the right arrow key.
          continue;
        }
        synthesizeKey("KEY_ArrowLeft");
        /* Strangely enough we need to hit "right arrow" three times to select two characters. */
        synthesizeKey("KEY_ArrowRight", {shiftKey: true});
        synthesizeKey("KEY_ArrowRight", {shiftKey: true});
        synthesizeKey("KEY_ArrowRight", {shiftKey: true});
        synthesizeKey("KEY_Delete");
        normalizeStyeAttributeValues(theDiv);

        /* We always expect to the delete the "tf" in "testfoo". */
        function makeNonCollapsedExpectation(aExpected) {
          return aExpected
            .replace("testfoo",
                     "tesoo")
            .replace("testfoo",
                     "tesoo")
            .replace("testwhite-space: pre;\">foo",
                     "teswhite-space: pre;\">oo")
            .replace("testwhite-space: pre;\">foo",
                     "teswhite-space: pre;\">oo")
            .replace("testwhite-space: pre;\">foo",
                     "teswhite-space: pre;\">oo")
            .replace("testwhite-space: pre;\">
foo",
                     "teswhite-space: pre;\">
oo")
            .replace("testpre\" style=\"white-space: pre;\">foo",
                     "tespre\" style=\"white-space: pre;\">oo")
            .replace("testpre\" style=\"white-space: pre;\">foo",
                     "tespre\" style=\"white-space: pre;\">oo")
            .replace("testpre\" style=\"white-space: pre;\">
foo",
                     "tespre\" style=\"white-space: pre;\">
oo");
        }
        const expected = makeNonCollapsedExpectation(tests[i][1]);
        if (tests[i].length == 2 || theDiv.innerHTML == expected) {
          is(theDiv.innerHTML, expected, "delete(non-collapsed): inner HTML for " + testName);
        } else {
          todoCount++;
          todo_is(theDiv.innerHTML, expected, "delete(non-collapsed, should be): inner HTML for " + testName);
          is(
            theDiv.innerHTML,
            makeNonCollapsedExpectation(tests[i][2]),
            "delete(non-collapsed, currently is): inner HTML for " + testName
          );
        }
        if (tests[i].length == 3) {
            ok(!!todoCount, `All tests unexpectedly passed in ${testName}`);
        }
      }

      SimpleTest.finish();
    });

  </script>

</pre>
</body>
</html>

100%


¤ Dauer der Verarbeitung: 0.33 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.