tor-browser

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

valueMode.html (10981B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Input element value mode</title>
      4 <link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <div id="log"></div>
      8 <script>
      9 // MODE DEFAULT
     10 test(function () {
     11  var input = document.createElement("input");
     12  input.type = "hidden";
     13  input.value = "foo\r\r\n\n\0";
     14  assert_equals(input.value, "foo\r\r\n\n\0");
     15 }, "value IDL attribute of input type hidden without value attribute");
     16 test(function() {
     17  var input = document.createElement("input");
     18  input.type = "hidden";
     19  input.setAttribute("value", "bar");
     20  input.value = "foo\r\r\n\n\0";
     21  assert_equals(input.value, "foo\r\r\n\n\0");
     22 }, "value IDL attribute of input type hidden with value attribute");
     23 
     24 test(function () {
     25  var input = document.createElement("input");
     26  input.type = "submit";
     27  input.value = "foo\r\r\n\n\0";
     28  assert_equals(input.value, "foo\r\r\n\n\0");
     29 }, "value IDL attribute of input type submit without value attribute");
     30 test(function() {
     31  var input = document.createElement("input");
     32  input.type = "submit";
     33  input.setAttribute("value", "bar");
     34  input.value = "foo\r\r\n\n\0";
     35  assert_equals(input.value, "foo\r\r\n\n\0");
     36 }, "value IDL attribute of input type submit with value attribute");
     37 
     38 test(function () {
     39  var input = document.createElement("input");
     40  input.type = "image";
     41  input.value = "foo\r\r\n\n\0";
     42  assert_equals(input.value, "foo\r\r\n\n\0");
     43 }, "value IDL attribute of input type image without value attribute");
     44 test(function() {
     45  var input = document.createElement("input");
     46  input.type = "image";
     47  input.setAttribute("value", "bar");
     48  input.value = "foo\r\r\n\n\0";
     49  assert_equals(input.value, "foo\r\r\n\n\0");
     50 }, "value IDL attribute of input type image with value attribute");
     51 
     52 test(function () {
     53  var input = document.createElement("input");
     54  input.type = "reset";
     55  input.value = "foo\r\r\n\n\0";
     56  assert_equals(input.value, "foo\r\r\n\n\0");
     57 }, "value IDL attribute of input type reset without value attribute");
     58 test(function() {
     59  var input = document.createElement("input");
     60  input.type = "reset";
     61  input.setAttribute("value", "bar");
     62  input.value = "foo\r\r\n\n\0";
     63  assert_equals(input.value, "foo\r\r\n\n\0");
     64 }, "value IDL attribute of input type reset with value attribute");
     65 
     66 test(function () {
     67  var input = document.createElement("input");
     68  input.type = "button";
     69  input.value = "foo\r\r\n\n\0";
     70  assert_equals(input.value, "foo\r\r\n\n\0");
     71 }, "value IDL attribute of input type button without value attribute");
     72 test(function() {
     73  var input = document.createElement("input");
     74  input.type = "button";
     75  input.setAttribute("value", "bar");
     76  input.value = "foo\r\r\n\n\0";
     77  assert_equals(input.value, "foo\r\r\n\n\0");
     78 }, "value IDL attribute of input type button with value attribute");
     79 
     80 // MODE DEFAULT/ON
     81 test(function () {
     82  var input = document.createElement("input");
     83  input.type = "checkbox";
     84  input.value = "foo\r\r\n\n\0";
     85  assert_equals(input.value, "foo\r\r\n\n\0");
     86 }, "value IDL attribute of input type checkbox without value attribute");
     87 test(function() {
     88  var input = document.createElement("input");
     89  input.type = "checkbox";
     90  input.setAttribute("value", "bar");
     91  input.value = "foo\r\r\n\n\0";
     92  assert_equals(input.value, "foo\r\r\n\n\0");
     93 }, "value IDL attribute of input type checkbox with value attribute");
     94 
     95 test(function () {
     96  var input = document.createElement("input");
     97  input.type = "radio";
     98  input.value = "foo\r\r\n\n\0";
     99  assert_equals(input.value, "foo\r\r\n\n\0");
    100 }, "value IDL attribute of input type radio without value attribute");
    101 test(function() {
    102  var input = document.createElement("input");
    103  input.type = "radio";
    104  input.setAttribute("value", "bar");
    105  input.value = "foo\r\r\n\n\0";
    106  assert_equals(input.value, "foo\r\r\n\n\0");
    107 }, "value IDL attribute of input type radio with value attribute");
    108 
    109 // MODE VALUE
    110 test(function () {
    111  var input = document.createElement("input");
    112  input.type = "text";
    113  input.value = "foo\r\r\n\n\0";
    114  assert_equals(input.value, "foo\0");
    115 }, "value IDL attribute of input type text without value attribute");
    116 test(function() {
    117  var input = document.createElement("input");
    118  input.type = "text";
    119  input.setAttribute("value", "bar");
    120  input.value = "foo\r\r\n\n\0";
    121  assert_equals(input.value, "foo\0");
    122 }, "value IDL attribute of input type text with value attribute");
    123 
    124 test(function () {
    125  var input = document.createElement("input");
    126  input.type = "search";
    127  input.value = "foo\r\r\n\n\0";
    128  assert_equals(input.value, "foo\0");
    129 }, "value IDL attribute of input type search without value attribute");
    130 test(function() {
    131  var input = document.createElement("input");
    132  input.type = "search";
    133  input.setAttribute("value", "bar");
    134  input.value = "foo\r\r\n\n\0";
    135  assert_equals(input.value, "foo\0");
    136 }, "value IDL attribute of input type search with value attribute");
    137 
    138 test(function () {
    139  var input = document.createElement("input");
    140  input.type = "tel";
    141  input.value = "foo\r\r\n\n\0";
    142  assert_equals(input.value, "foo\0");
    143 }, "value IDL attribute of input type tel without value attribute");
    144 test(function() {
    145  var input = document.createElement("input");
    146  input.type = "tel";
    147  input.setAttribute("value", "bar");
    148  input.value = "foo\r\r\n\n\0";
    149  assert_equals(input.value, "foo\0");
    150 }, "value IDL attribute of input type tel with value attribute");
    151 
    152 test(function () {
    153  var input = document.createElement("input");
    154  input.type = "url";
    155  input.value = "foo\r\r\n\n\0";
    156  assert_equals(input.value, "foo\0");
    157 }, "value IDL attribute of input type url without value attribute");
    158 test(function() {
    159  var input = document.createElement("input");
    160  input.type = "url";
    161  input.setAttribute("value", "bar");
    162  input.value = "foo\r\r\n\n\0";
    163  assert_equals(input.value, "foo\0");
    164 }, "value IDL attribute of input type url with value attribute");
    165 
    166 test(function () {
    167  var input = document.createElement("input");
    168  input.type = "email";
    169  input.value = "foo\r\r\n\n\0";
    170  assert_equals(input.value, "foo\0");
    171 }, "value IDL attribute of input type email without value attribute");
    172 test(function() {
    173  var input = document.createElement("input");
    174  input.type = "email";
    175  input.setAttribute("value", "bar");
    176  input.value = "foo\r\r\n\n\0";
    177  assert_equals(input.value, "foo\0");
    178 }, "value IDL attribute of input type email with value attribute");
    179 
    180 test(function () {
    181  var input = document.createElement("input");
    182  input.type = "password";
    183  input.value = "foo\r\r\n\n\0";
    184  assert_equals(input.value, "foo\0");
    185 }, "value IDL attribute of input type password without value attribute");
    186 test(function() {
    187  var input = document.createElement("input");
    188  input.type = "password";
    189  input.setAttribute("value", "bar");
    190  input.value = "foo\r\r\n\n\0";
    191  assert_equals(input.value, "foo\0");
    192 }, "value IDL attribute of input type password with value attribute");
    193 
    194 test(function () {
    195  var input = document.createElement("input");
    196  input.type = "datetime-local";
    197  input.value = "foo\r\r\n\n\0";
    198  assert_equals(input.value, "");
    199 }, "value IDL attribute of input type datetime-local without value attribute");
    200 test(function() {
    201  var input = document.createElement("input");
    202  input.type = "datetime-local";
    203  input.setAttribute("value", "bar");
    204  input.value = "foo\r\r\n\n\0";
    205  assert_equals(input.value, "");
    206 }, "value IDL attribute of input type datetime-local with value attribute");
    207 
    208 test(function () {
    209  var input = document.createElement("input");
    210  input.type = "date";
    211  input.value = "foo\r\r\n\n\0";
    212  assert_equals(input.value, "");
    213 }, "value IDL attribute of input type date without value attribute");
    214 test(function() {
    215  var input = document.createElement("input");
    216  input.type = "date";
    217  input.setAttribute("value", "bar");
    218  input.value = "foo\r\r\n\n\0";
    219  assert_equals(input.value, "");
    220 }, "value IDL attribute of input type date with value attribute");
    221 
    222 test(function () {
    223  var input = document.createElement("input");
    224  input.type = "time";
    225  input.value = "foo\r\r\n\n\0";
    226  assert_equals(input.value, "");
    227 }, "value IDL attribute of input type time without value attribute");
    228 test(function() {
    229  var input = document.createElement("input");
    230  input.type = "time";
    231  input.setAttribute("value", "bar");
    232  input.value = "foo\r\r\n\n\0";
    233  assert_equals(input.value, "");
    234 }, "value IDL attribute of input type time with value attribute");
    235 
    236 test(function () {
    237  var input = document.createElement("input");
    238  input.type = "number";
    239  input.value = "foo\r\r\n\n\0";
    240  assert_equals(input.value, "");
    241 }, "value IDL attribute of input type number without value attribute");
    242 test(function() {
    243  var input = document.createElement("input");
    244  input.type = "number";
    245  input.setAttribute("value", "bar");
    246  input.value = "foo\r\r\n\n\0";
    247  assert_equals(input.value, "");
    248 }, "value IDL attribute of input type number with value attribute");
    249 
    250 test(function () {
    251  var input = document.createElement("input");
    252  input.type = "range";
    253  input.value = "foo\r\r\n\n\0";
    254  assert_equals(input.value, "50");
    255 }, "value IDL attribute of input type range without value attribute");
    256 test(function() {
    257  var input = document.createElement("input");
    258  input.type = "range";
    259  input.setAttribute("value", "bar");
    260  input.value = "foo\r\r\n\n\0";
    261  assert_equals(input.value, "50");
    262 }, "value IDL attribute of input type range with value attribute");
    263 
    264 test(function () {
    265  var input = document.createElement("input");
    266  input.type = "color";
    267  input.value = "foo\r\r\n\n\0";
    268  assert_equals(input.value, "#000000");
    269 }, "value IDL attribute of input type color without value attribute");
    270 test(function() {
    271  var input = document.createElement("input");
    272  input.type = "color";
    273  input.setAttribute("value", "bar");
    274  input.value = "foo\r\r\n\n\0";
    275  assert_equals(input.value, "#000000");
    276 }, "value IDL attribute of input type color with value attribute");
    277 
    278 // MODE FILENAME
    279 test(function () {
    280  var input = document.createElement("input");
    281  input.type = "file";
    282 
    283  for (const emptyValue of ["", null]) {
    284    input.value = emptyValue;
    285    assert_equals(input.value, "", `input.value is empty after assigning ${emptyValue}`);
    286  }
    287 
    288  for (const invalidValue of ["foo", 10, undefined]) {
    289    assert_throws_dom("InvalidStateError", () => {
    290      input.value = invalidValue;
    291    });
    292    assert_equals(input.value, "", `input.value is empty after assigning ${invalidValue}`);
    293  }
    294 }, "value IDL attribute of input type file without value attribute");
    295 test(function() {
    296  var input = document.createElement("input");
    297  input.type = "file";
    298  input.setAttribute("value", "bar");
    299  assert_equals(input.value, "", "input.value is empty even with a value attribute");
    300 
    301  input.value = "";
    302  assert_equals(input.getAttribute("value"), "bar", "Setting input.value does not change the value attribute");
    303 }, "value IDL attribute of input type file with value attribute");
    304 </script>