tor-browser

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

option-text-spaces.html (3030B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>HTMLOptionElement.text</title>
      4 <link rel=author title=Ms2ger href="mailto:Ms2ger@gmail.com">
      5 <link rel=help href="https://html.spec.whatwg.org/multipage/#dom-option-text">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <div id=log></div>
      9 <script>
     10 test(function() {
     11  var spaces = ["\u0020", "\u0009", "\u000A", "\u000C", "\u000D"];
     12  spaces.forEach(function(space) {
     13    test(function() {
     14      var option = document.createElement("option");
     15      option.textContent = space + "text";
     16      assert_equals(option.text, "text");
     17    }, "option.text should strip leading space characters (" +
     18        format_value(space) + ")");
     19  });
     20  spaces.forEach(function(space) {
     21    test(function() {
     22      var option = document.createElement("option");
     23      option.textContent = "text" + space;
     24      assert_equals(option.text, "text");
     25    }, "option.text should strip trailing space characters (" +
     26        format_value(space) + ")");
     27  });
     28  spaces.forEach(function(space) {
     29    test(function() {
     30      var option = document.createElement("option");
     31      option.textContent = space + "text" + space;
     32      assert_equals(option.text, "text");
     33    }, "option.text should strip leading and trailing space characters (" +
     34        format_value(space) + ")");
     35  });
     36  spaces.forEach(function(space) {
     37    test(function() {
     38      var option = document.createElement("option");
     39      option.textContent = "before" + space + "after";
     40      assert_equals(option.text, "before after");
     41    }, "option.text should replace single internal space characters (" +
     42        format_value(space) + ")");
     43  });
     44  spaces.forEach(function(space1) {
     45    spaces.forEach(function(space2) {
     46      test(function() {
     47        var option = document.createElement("option");
     48        option.textContent = "before" + space1 + space2 + "after";
     49        assert_equals(option.text, "before after");
     50      }, "option.text should replace multiple internal space characters (" +
     51          format_value(space1) + ", " + format_value(space2) + ")");
     52    });
     53  });
     54  test(function() {
     55    var option = document.createElement("option");
     56    option.textContent = "\u00a0text";
     57    assert_equals(option.text, "\u00a0text");
     58  }, "option.text should leave leading NBSP alone.");
     59  test(function() {
     60    var option = document.createElement("option");
     61    option.textContent = "text\u00a0";
     62    assert_equals(option.text, "text\u00a0");
     63  }, "option.text should leave trailing NBSP alone.");
     64  test(function() {
     65    var option = document.createElement("option");
     66    option.textContent = "before\u00a0after";
     67    assert_equals(option.text, "before\u00a0after");
     68  }, "option.text should leave a single internal NBSP alone.");
     69  test(function() {
     70    var option = document.createElement("option");
     71    option.textContent = "before\u00a0\u00a0after";
     72    assert_equals(option.text, "before\u00a0\u00a0after");
     73  }, "option.text should leave two internal NBSPs alone.");
     74 });
     75 </script>