tor-browser

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

selection-weekmonth.html (1997B)


      1 <!DOCTYPE HTML>
      2 <title>Input element programmatic selection support</title>
      3 <link rel="author" title="yaycmyk" href="mailto:evan@yaycmyk.com">
      4 <link rel="help" href="https://html.spec.whatwg.org/multipage/forms.html#dom-textarea/input-select">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <div id="log"></div>
      8 <script>
      9 
     10 /* all textual, non-hidden inputs support .select() */
     11 test(function() {
     12  var valid = [
     13    "month",
     14    "week",
     15  ];
     16 
     17  valid.forEach(function(type) {
     18    test(function() {
     19      var input = document.createElement("input");
     20      var a;
     21 
     22      input.type = type;
     23      assert_equals(input.type, type, "the given input type is not supported");
     24 
     25      input.select();
     26 
     27    }, "input type " + type + " should support the select() method");
     28  });
     29 });
     30 
     31 /* only certain input types are allowed to have a variable-length selection */
     32 test(function() {
     33  var invalid = [
     34    "month",
     35    "week",
     36  ];
     37 
     38  invalid.forEach(function(type) {
     39    test(function() {
     40      var input = document.createElement("input");
     41 
     42      input.type = type;
     43      assert_equals(input.type, type, "the given input type is not supported");
     44 
     45      assert_equals(input.selectionStart, null, 'getting input.selectionStart');
     46      assert_throws_dom("INVALID_STATE_ERR", function() { input.selectionStart = 0; });
     47      assert_equals(input.selectionEnd, null, 'getting input.selectionEnd');
     48      assert_throws_dom("INVALID_STATE_ERR", function() { input.selectionEnd = 0; });
     49      assert_equals(input.selectionDirection, null, 'getting input.selectionDirection');
     50      assert_throws_dom("INVALID_STATE_ERR", function() { input.selectionDirection = "none"; });
     51      assert_throws_dom("INVALID_STATE_ERR", function() { input.setSelectionRange(0, 0); });
     52      assert_throws_dom("INVALID_STATE_ERR", function() { input.setRangeText('', 0, 0); });
     53 
     54    }, "input type " + type + " should not support variable-length selections");
     55  });
     56 });
     57 </script>