tor-browser

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

innertext-setter-tests.js (2973B)


      1 testText("<div>", "abc", "abc", "Simplest possible test");
      2 testHTML("<div>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in non-white-space:pre elements");
      3 testHTML("<pre>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in <pre> element");
      4 testHTML("<textarea>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in <textarea> element");
      5 testHTML("<div style='white-space:pre'>", "abc\ndef", "abc<br>def", "Newlines convert to <br> in white-space:pre element");
      6 testHTML("<div>", "abc\rdef", "abc<br>def", "CRs convert to <br> in non-white-space:pre elements");
      7 testHTML("<pre>", "abc\rdef", "abc<br>def", "CRs convert to <br> in <pre> element");
      8 testHTML("<div>", "abc\r\ndef", "abc<br>def", "Newline/CR pair converts to <br> in non-white-space:pre element");
      9 testHTML("<div>", "abc\n\ndef", "abc<br><br>def", "Newline/newline pair converts to two <br>s in non-white-space:pre element");
     10 testHTML("<div>", "abc\r\rdef", "abc<br><br>def", "CR/CR pair converts to two <br>s in non-white-space:pre element");
     11 testHTML("<div style='white-space:pre'>", "abc\rdef", "abc<br>def", "CRs convert to <br> in white-space:pre element");
     12 testText("<div>", "abc<def", "abc<def", "< preserved");
     13 testText("<div>", "abc>def", "abc>def", "> preserved");
     14 testText("<div>", "abc&", "abc&", "& preserved");
     15 testText("<div>", "abc\"def", "abc\"def", "\" preserved");
     16 testText("<div>", "abc\'def", "abc\'def", "\' preserved");
     17 testHTML("<svg>", "abc", "", "innerText not supported on SVG elements");
     18 testHTML("<math>", "abc", "", "innerText not supported on MathML elements");
     19 testText("<div>", "abc\0def", "abc\0def", "Null characters preserved");
     20 testText("<div>", "abc\tdef", "abc\tdef", "Tabs preserved");
     21 testText("<div>", " abc", " abc", "Leading whitespace preserved");
     22 testText("<div>", "abc ", "abc ", "Trailing whitespace preserved");
     23 testText("<div>", "abc  def", "abc  def", "Whitespace not compressed");
     24 testText("<div>abc\n\n", "abc", "abc", "Existing text deleted");
     25 testText("<div><br>", "abc", "abc", "Existing <br> deleted");
     26 testHTML("<div>", "", "", "Assigning the empty string");
     27 testHTML("<div>", null, "", "Assigning null");
     28 testHTML("<div>", undefined, "undefined", "Assigning undefined");
     29 testHTML("<div>", "\rabc", "<br>abc", "Start with CR");
     30 testHTML("<div>", "\nabc", "<br>abc", "Start with LF");
     31 testHTML("<div>", "\r\nabc", "<br>abc", "Start with CRLF");
     32 testHTML("<div>", "abc\r", "abc<br>", "End with CR");
     33 testHTML("<div>", "abc\n", "abc<br>", "End with LF");
     34 testHTML("<div>", "abc\r\n", "abc<br>", "End with CRLF");
     35 
     36 // Setting innerText on these should not throw
     37 ["area", "base", "basefont", "bgsound", "br", "col", "embed", "frame", "hr",
     38 "image", "img", "input", "keygen", "link", "menuitem", "meta", "param",
     39 "source", "track", "wbr", "colgroup", "frameset", "head", "html", "table",
     40 "tbody", "tfoot", "thead", "tr"].forEach(function(tag) {
     41  testText(document.createElement(tag), "abc", "abc", "innerText on <" + tag + "> element");
     42 });