Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/naga/src/common/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 81 B image not shown  

Quelle  test_lineboundary.html   Sprache: unbekannt

 
<!DOCTYPE html>
<html>
<head>
  <title>Line boundary getText* functions tests</title>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../text.js"></script>
  <script type="application/javascript">
    function doTest() {
      testTextAtOffset("line_test_1", BOUNDARY_LINE_START,
                       [[06"Line 1 "07],
                        // See the kOk test below.
                        // [77, kEmbedChar, 78],
                        [815"Line 3 "815]]);
      testTextAtOffset(/* aOffset */ 7, BOUNDARY_LINE_START,
        kEmbedChar, /* aStartOffset */ 7, /* aEndOffset */ 8,
        "line_test_1",
        /* returned text */ kOk,
        /* returned start offset */ kOk, /* returned end offset */ kOk);

      // ////////////////////////////////////////////////////////////////////////
      // __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__
      //  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15

      var IDs = [ "input""div""editable""textarea",
                  getNode("ta", getNode("ta_cntr").contentDocument) ];

      testTextBeforeOffset(IDs, BOUNDARY_LINE_START,
                           [ [ 015""00 ] ]);
      testTextBeforeOffset(IDs, BOUNDARY_LINE_END,
                           [ [ 015""00 ] ]);

      testTextAtOffset(IDs, BOUNDARY_LINE_START,
                       [ [ 015"hello my friend"015 ] ]);
      testTextAtOffset(IDs, BOUNDARY_LINE_END,
                       [ [ 015"hello my friend"015 ] ]);

      testTextAfterOffset(IDs, BOUNDARY_LINE_START,
                          [ [ 015""1515 ] ]);
      testTextAfterOffset(IDs, BOUNDARY_LINE_END,
                          [ [ 015""1515 ] ]);

      // ////////////////////////////////////////////////////////////////////////
      // __o__n__e__w__o__r__d__\n
      //  0  1  2  3  4  5  6  7
      // __\n
      //  8
      // __t__w__o__ __w__o__r__d__s__\n
      //  9 10 11 12 13 14 15 16 17 18

      IDs = [ "ml_div""ml_divbr""ml_editable""ml_editablebr""ml_textarea"];

      testTextBeforeOffset(IDs, BOUNDARY_LINE_START,
                           [ [ 07""00 ],
                             [ 88"oneword\n"08 ],
                             [ 918"\n"89 ],
                             [ 1919"two words\n"919 ]]);

      testTextBeforeOffset(IDs, BOUNDARY_LINE_END,
                          [ [ 07""00 ],
                            [ 88"oneword"07 ],
                            [ 918"\n"78 ],
                            [ 1919"\ntwo words"818 ]]);

      testTextAtOffset(IDs, BOUNDARY_LINE_START,
                       [ [ 07"oneword\n"08 ],
                         [ 88"\n"89 ],
                         [ 918"two words\n"919 ],
                         [ 1919""1919 ]]);
      testTextAtOffset(IDs, BOUNDARY_LINE_END,
                       [ [ 07"oneword"07 ],
                         [ 88"\n"78 ],
                         [ 918"\ntwo words"818 ],
                         [ 1919"\n"1819 ]]);

      testTextAfterOffset(IDs, BOUNDARY_LINE_START,
                          [ [ 07"\n"89 ],
                            [ 88"two words\n"919 ],
                            [ 919""1919 ]]);
      testTextAfterOffset(IDs, BOUNDARY_LINE_END,
                          [ [ 07"\n"78 ],
                            [ 88"\ntwo words"818 ],
                            [ 918"\n"1819 ],
                            [ 1919""1919 ]]);

      // ////////////////////////////////////////////////////////////////////////
      // a * b (* is embedded char for link)
      testTextBeforeOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
                           [ [ 05""00 ] ]);

      testTextBeforeOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
                           [ [ 05""00 ] ]);

      testTextAtOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
                       [ [ 05"a " + kEmbedChar + " c"05 ] ]);

      testTextAtOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
                       [ [ 05"a " + kEmbedChar + " c"05 ] ]);

      testTextAfterOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_START,
                          [ [ 05""55 ] ]);

      testTextAfterOffset([ getAccessible("ht_1").firstChild ], BOUNDARY_LINE_END,
                          [ [ 05""55 ] ]);

      // ////////////////////////////////////////////////////////////////////////
      // foo<br> and foo<br><br>

      testTextAtOffset([ getAccessible("ht_2").firstChild.firstChild ],
                       BOUNDARY_LINE_START,
                       [ [ 03"foo\n"04 ] ]);
      testTextAtOffset([ getAccessible("ht_3").firstChild.firstChild ],
                       BOUNDARY_LINE_START,
                       [ [ 03"foo\n"04 ], [ 44"\n"45 ] ]);

      // ////////////////////////////////////////////////////////////////////////
      // 'Hello world ' (\n is rendered as space)

      testTextAtOffset([ "ht_4" ], BOUNDARY_LINE_START,
                       [ [ 012"Hello world "012 ] ]);

      // ////////////////////////////////////////////////////////////////////////
      // list items

      testTextAtOffset([ "li1" ], BOUNDARY_LINE_START,
                       [ [ 06, kDiscBulletText + "Item"06 ] ]);
      testTextAtOffset([ "li2" ], BOUNDARY_LINE_START,
                       [ [ 02, kDiscBulletText, 02 ] ]);
      testTextAtOffset([ "li3" ], BOUNDARY_LINE_START,
                       [ [ 08, kDiscBulletText + "a long "09 ],
                         [ 912"and "913 ] ]);
      testTextAtOffset([ "li4" ], BOUNDARY_LINE_START,
                       [ [ 07, kDiscBulletText + "a " + kEmbedChar + " c"07 ] ]);
      testTextAtOffset([ "li5" ], BOUNDARY_LINE_START,
                       [ [ 02, kDiscBulletText + "\n"03 ],
                         [ 37"hello"38 ] ]);
      testTextAtOffset([ "ul1" ], BOUNDARY_LINE_START,
                       [ [ 00, kEmbedChar, 01 ],
                         [ 11, kEmbedChar, 12 ],
                         [ 22, kEmbedChar, 23 ],
                         [ 33, kEmbedChar, 34 ],
                         [ 45, kEmbedChar, 45 ] ]);

      testTextAtOffset([ "li6" ], BOUNDARY_LINE_START,
                       [ [ 07"1. Item"07 ] ]);
      testTextAtOffset([ "li7" ], BOUNDARY_LINE_START,
                       [ [ 03"2. "03 ] ]);
      testTextAtOffset([ "li8" ], BOUNDARY_LINE_START,
                       [ [ 09"3. a long "010 ],
                         [ 1013"and "1014 ] ]);
      testTextAtOffset([ "li9" ], BOUNDARY_LINE_START,
                       [ [ 08"4. a " + kEmbedChar + " c"08 ] ]);
      testTextAtOffset([ "li10" ], BOUNDARY_LINE_START,
                       [ [ 03"5. \n"04 ],
                         [ 48"hello"49 ] ]);
      testTextAtOffset([ "ol1" ], BOUNDARY_LINE_START,
                       [ [ 00, kEmbedChar, 01 ],
                         [ 11, kEmbedChar, 12 ],
                         [ 22, kEmbedChar, 23 ],
                         [ 33, kEmbedChar, 34 ],
                         [ 45, kEmbedChar, 45 ] ]);

      // ////////////////////////////////////////////////////////////////////////
      // Nested hypertexts

      testTextAtOffset(["ht_5" ], BOUNDARY_LINE_START,
                       [ [ 00, kEmbedChar, 01 ] ]);

      // ////////////////////////////////////////////////////////////////////////
      // Block followed by list

      testTextAtOffset([ "block_then_ul" ], BOUNDARY_LINE_START,
                       [ [ 00, kEmbedChar, 01 ],
                         [ 11, kEmbedChar, 12 ] ]);

      // Embedded char containing a line break breaks line offsets in parent.
      testTextAtOffset([ "brInEmbed" ], BOUNDARY_LINE_START,
                       [ [01"a " + kEmbedChar, 03],
                         [22"a " + kEmbedChar + " d"05],
                         [35, kEmbedChar + " d"25] ]);
      testTextAtOffset([ "brInEmbedAndBefore" ], BOUNDARY_LINE_START,
                       [ [01"a\n"02],
                         [23"b " + kEmbedChar, 25],
                         [44"b " + kEmbedChar + " e"27],
                         [57, kEmbedChar + " e"47] ]);
      testTextAtOffset([ "brInEmbedAndAfter" ], BOUNDARY_LINE_START,
                       [ [01"a " + kEmbedChar, 03],
                         [22"a " + kEmbedChar + " d\n"06],
                         [35, kEmbedChar + " d\n"26],
                         [67"e"67] ]);
      testTextAtOffset([ "brInEmbedAndBlockElementAfter" ], BOUNDARY_LINE_START,
                       [ [02"a " + kEmbedChar, 03],
                         [34, kEmbedChar, 34] ]);
      testTextAtOffset([ "brInEmbedThenTextThenBlockElement" ], BOUNDARY_LINE_START,
                       [ [01"a " + kEmbedChar, 03],
                         [22"a " + kEmbedChar + " d"05],
                         [34, kEmbedChar + " d"25],
                         [56, kEmbedChar, 56] ]);
      testTextAtOffset([ "noBrInEmbedButOneBefore" ], BOUNDARY_LINE_START,
                       [ [01"a\n"02],
                         [27"b " + kEmbedChar + " d"27] ]);
      testTextAtOffset([ "noBrInEmbedButOneAfter" ], BOUNDARY_LINE_START,
                       [ [03"a " + kEmbedChar + "\n"04],
                         [45"c"45] ]);
      testTextAtOffset([ "twoEmbedsWithBRs" ], BOUNDARY_LINE_START,
                       [ [01"a " + kEmbedChar, 03],
                         [22"a " + kEmbedChar + kEmbedChar, 04],
                         [33, kEmbedChar + kEmbedChar + " f"26],
                         [46, kEmbedChar + " f"36] ]);

      // Inline block span with nested spans and BRs
      testTextAtOffset([ "inlineBlockWithSpansAndBrs" ], BOUNDARY_LINE_START,
                       [ [01"a\n"02],
                         [23"b\n"24],
                         [45"c"45] ]);

      // Spans with BRs and whitespaces.      
      testTextAtOffset([ "spansWithWhitespaces" ], BOUNDARY_LINE_START,
                       [ [06"Line 1\n"07],
                         [713"Line 2\n"714],
                         [1420"Line 3\n"1421],
                         [2127"Line 4\n"2128],
                         [2828""2828] ]);

      // A line with an empty display: contents leaf in the middle.
      testTextAtOffset([ "displayContents" ], BOUNDARY_LINE_START,
                       // See the kOk test below.
                       // [ [03, `a${kEmbedChar}b`, 03] ]);
                       [ [00, `a${kEmbedChar}b`, 03],
                         [23, `a${kEmbedChar}b`, 03] ]);
      testTextAtOffset(/* aOffset */ 1, BOUNDARY_LINE_START,
        `a${kEmbedChar}b`, /* aStartOffset */ 0, /* aEndOffset */ 3,
        "displayContents",
        /* returned text */ kOk,
        /* returned start offset */ kOk,
        /* returned end offset */ kOk);

      // A line which wraps, followed by a br, followed by another line.
      testTextAtOffset([ "brAfterWrapped" ], BOUNDARY_LINE_START,
                       [ [01"a "02],
                         [23"b\n"24],
                         [45"c"45] ]);

      testTextAtOffset([ "inlineInput" ], BOUNDARY_LINE_END,
                       [ [01"a"01],
                         [27, `\nb ${kEmbedChar} d`, 17,
                          [ [ 4"inlineInput", kOk, kOk, kOk] ] ] ]);

      testTextAtOffset([ "inlineInput2" ], BOUNDARY_LINE_END,
                       [ [01"a"01],
                         [27, `\n${kEmbedChar} c d`, 17,
                          [ [ 2"inlineInput2", kOk, kOk, kOk] ] ] ]);

      testTextAtOffset([ "inlineInput3" ], BOUNDARY_LINE_END,
                       [ [01"a"01],
                         [28, `\nb${kEmbedChar} c d`, 18,
                          [ [ 3"inlineInput3", kOk, kOk, kOk] ] ] ]);

      testTextAtOffset([ "inlineInput4" ], BOUNDARY_LINE_END,
                       [ [01"a"01],
                         [27, `\n${kEmbedChar}b c d`, 18,
                          [ [ 2"inlineInput4", kOk, kOk, kOk ] ] ] ]);

      testTextAtOffset(/* aOffset */ 0, BOUNDARY_LINE_START,
        kEmbedChar, 01"contentEditableTable",
          /* returned text */ kOk,
          /* returned start offset */ kOk,
          /* returned end offset */ kOk);

      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>
</head>
<body>

  <a target="_blank"
     title="getTextAtOffset for word boundaries: beginning of a new life"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=853340">
    Bug 853340
  </a>
  <a target="_blank"
     title="getTextBeforeOffset for word boundaries: evolving"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=855732">
    Bug 855732
  </a>
  <a target="_blank"
     title=" getTextAfterOffset for line boundary on new rails"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=882292">
    Bug 882292
  </a>
  <a target="_blank"
     title="getTextAtOffset broken for last object when closing tag is preceded by newline char"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=947170">
    Bug 947170
  </a>

  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <input id="input" value="hello my friend"/>
  <div id="div">hello my friend</div>
  <div id="editable" contenteditable="true">hello my friend</div>
  <textarea id="textarea">hello my friend</textarea>
  <iframe id="ta_cntr"
          src="data:text/html,<html><body><textarea id='ta'>hello my friend</textarea></body></html>"></iframe>

  <pre>
    <div id="ml_div" style="border-style:outset;">oneword

two words
</div>
  <div id="ml_divbr" style="border-style:outset;">oneword<br/><br/>two words<br/></div>
  <div id="ml_editable" style="border-style:outset;" contenteditable="true">oneword

two words
</div>
  <div id="ml_editablebr" contenteditable="true" style="border-style:outset;">oneword<br/><br/>two words<br/></div>
  <textarea id="ml_textarea" cols="300">oneword

two words
</textarea>
  </pre>

  <iframe id="ht_1" src="data:text/html,<html><body>a <a href=''>b</a> c</body></html>"></iframe>

  <iframe id="ht_2" src="data:text/html,<div contentEditable='true'>foo<br/></div>"></iframe>
  <iframe id="ht_3" src="data:text/html,<div contentEditable='true'>foo<br/><br/></div>"></iframe>

  <p id="ht_4">Hello world
</p>

  <ul id="ul1">
    <li id="li1">Item</li>
    <li id="li2"></li>
    <li id="li3" style="font-family:monospace; font-size:10pt; width:8ch;">a long and winding road that lead me to your door</li>
    <li id="li4">a <a href=''>b</a> c</li>
    <li id="li5"><br>hello</li>
  </ul>

  <ol id="ol1">
    <li id="li6">Item</li>
    <li id="li7"></li>
    <li id="li8" style="font-family:monospace; font-size:10pt; width:8ch;">a long and winding road that lead me to your door</li>
    <li id="li9">a <a href=''>b</a> c</li>
    <li id="li10"><br>hello</li>
  </ol>

  <div id="ht_5">
    <div>
      <p>sectiounus</p>
      <p>seciofarus</p>
    </div>
  </div>
  <div id="line_test_1">
    Line 1
    <center><input type="TEXT"><input value="Button" type="SUBMIT"></center>
    Line 3
  </div>

  <div id="block_then_ul">
    <p>Block</p>
    <ul><li>Li</li></ul>
  </div>
  <div id="brInEmbed" contenteditable>a <a href="https://mozilla.org/">b<br>c</a> d</div>
  <div id="brInEmbedAndBefore">a<br>b <a href="https://mozilla.org/">c<br>d</a> e</div>
  <div id="brInEmbedAndAfter">a <a href="https://mozilla.org/">b<br>c</a> d<br>e</div>
  <div id="brInEmbedAndBlockElementAfter">a <a href="https://mozilla.org/">b<br>c</a><p>d</p></div>
  <div id="brInEmbedThenTextThenBlockElement">a <a href="https://mozilla.org/">b<br>c</a> d<p>e</p></div>
  <div id="noBrInEmbedButOneBefore">a<br>b <a href="https://mozilla.org/">c</a> d</div>
  <div id="noBrInEmbedButOneAfter">a <a href="https://mozilla.org/">b</a><br>c</div>
  <div id="twoEmbedsWithBRs">a <a href="https://mozilla.org">b<br>c</a><a href="https://mozilla.org">d<br>e</a> f</div>
  <span id="inlineBlockWithSpansAndBrs" style="display: inline-block;"><span>a<br>b<br><span></span></span>c</span>
  <div id="spansWithWhitespaces">    <!-- Don't indent the following block -->
<span>Line 1<br/>
</span>
<span>Line 2<br/>
</span>
<span>Line 3<br/>
</span>
<span>Line 4<br/>
</span></div><!-- OK to indent again -->
  <div id="displayContents">a<ul style="display: contents;"><li style="display: contents;"></li></ul>b</div>
  <div id="brAfterWrapped" style="width: 10px;">a b<br>c</div>
  <div id="inlineInput">a<br>b <input value="c"> d</div>
  <div id="inlineInput2">a<br><input value="b"> c d</div>
  <div id="inlineInput3">a<br> b<input value=""> c d</div>
  <div id="inlineInput4">a<br><input value="">b c d</div>
  <div id="contentEditableTable" contenteditable>
    <table style="display: inline-table">
      <thead>
        <th>Foo</th>
      </thead>
      <tbody>
        <tr>
          <td>Bar</td>
        </tr>
      </tbody>
    </table>
    <br>
    <table style="display: inline-table">
      <thead>
        <th>Foo</th>
      </thead>
      <tbody>
        <tr>
          <td>Bar</td>
        </tr>
      </tbody>
    </table>
    <br>
  </div>
</body>
</html>

Messung V0.5 in Prozent
C=99 H=100 G=99

[Dauer der Verarbeitung: 0.44 Sekunden, vorverarbeitet 2026-06-05]