tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

innertext-whitespace-pre-line.html (1125B)


      1 <!DOCTYPE html>
      2 <title>innerText with white-space:pre-line</title>
      3 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1923829">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <div id="a" style="white-space: pre-line">one&#10;two&#10;three&#10;four</div>
      8 
      9 <div id="b" style="white-space: pre">one&#10;two&#10;three&#10;four</div>
     10 
     11 <div id="c" style="white-space: pre-line">
     12 one
     13  two
     14    <!-- comment -->
     15   three
     16    four
     17 </div>
     18 
     19 <div id="d" style="white-space: pre">
     20 one
     21  two
     22    <!-- comment -->
     23   three
     24    four
     25 </div>
     26 
     27 <script>
     28 test(() => {
     29  assert_equals(a.innerText, b.innerText);
     30 }, "innerText should be the same for the pre-line and pre examples");
     31 
     32 test(() => {
     33  function collapseWhitespace(s) {
     34    return s.replace(/  +/g, ' ')  // collapse runs of spaces
     35            .replace(/ $/mg, '')   // strip trailing spaces
     36            .replace(/^ /mg, '');  // strip leading spaces
     37  }
     38  assert_equals(c.innerText, collapseWhitespace(d.innerText));
     39 }, "innerText has collapsed whitespace but preserved newlines with pre-line");
     40 </script>