tor-browser

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

files.html (2337B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>HTMLInputElement#files</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <div id=log></div>
      7 <script>
      8 var types = [
      9  "hidden",
     10  "text",
     11  "search",
     12  "tel",
     13  "url",
     14  "email",
     15  "password",
     16  "date",
     17  "month",
     18  "week",
     19  "time",
     20  "datetime-local",
     21  "number",
     22  "range",
     23  "color",
     24  "checkbox",
     25  "radio",
     26  "submit",
     27  "image",
     28  "reset",
     29  "button",
     30 ];
     31 
     32 types.forEach(function(type) {
     33  test(function() {
     34    const input = document.createElement("input"),
     35          input2 = document.createElement("input");
     36    input.type = type;
     37    input2.type = "file";
     38    assert_equals(input.files, null, "files should be null");
     39 
     40    input.files = input2.files;
     41    assert_equals(input.files, null, "files should remain null as it cannot be set when it does not apply");
     42  }, "files for input type=" + type);
     43 });
     44 
     45 test(function() {
     46  var input = document.createElement("input");
     47  input.type = "file";
     48  assert_not_equals(input.files, null);
     49  assert_true(input.files instanceof FileList, "files should be a FileList");
     50  var files = input.files;
     51  assert_equals(input.files, files, "files should return the same object");
     52 }, "files for input type=file");
     53 
     54 test(() => {
     55  const i1 = document.createElement("input"),
     56        i2 = document.createElement("input");
     57  i1.type = "file";
     58  i2.type = "file";
     59 
     60  const files = i2.files;
     61  i1.files = i2.files;
     62  assert_equals(i1.files, files, "FileList should not be copied");
     63  assert_equals(i2.files, files, "FileList can be shared across input elements");
     64 
     65  i1.files = null;
     66  assert_equals(i1.files, files, "files cannot be set to null");
     67 
     68  assert_throws_js(TypeError, () => i1.files = [], "files cannot be set to an array");
     69  assert_throws_js(TypeError, () => i1.files = [new File([], "x")], "files cannot be set to an array (even when it contains File objects)");
     70 }, "setting <input type=file>.files");
     71 
     72 test(() => {
     73  const i = document.createElement("input");
     74  i.type = "file";
     75 
     76  let dt = new DataTransfer();
     77 
     78  const files = dt.files;
     79  i.files = files;
     80  assert_equals(i.files, files, "FileList should not be copied");
     81  assert_equals(dt.files, files, "FileList can be shared across input / DataTransfer");
     82 }, "setting <input type=file>.files from DataTransfer");
     83 </script>