summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/editing/dnd/platform/file-to-system.html
blob: f80d5f43c2090a71d94e28bbf274de42c632ee0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!doctype html>
<html>
  <head>
    <title>Dragging a file to the system</title>
    <style type="text/css">
span { display: inline-block; height: 100px; width: 100px; background: orange; }
    </style>
    <script type="text/javascript">
window.onload = function () {
  var drag = document.getElementsByTagName('span')[0];
  drag.ondragstart = function (e) {
    e.dataTransfer.setData('text','PASS');
    e.dataTransfer.effectAllowed = 'copy';
    var filein = document.getElementsByTagName('input')[0];
    if( !filein.files ) {
      document.getElementsByTagName('p')[0].innerHTML = 'FAIL - file API is not supported.';
      return;
    }
    if( !filein.files[0] ) {
      document.getElementsByTagName('p')[0].innerHTML = 'FAIL - no file was found in the file input.';
      return;
    }
    var thefile = filein.files[0];
    try {
      e.dataTransfer.items.add(thefile);
    } catch(err) {
      document.getElementsByTagName('p')[0].innerHTML = 'FAIL - error when adding file';
      e.preventDefault();
      return;
    }
    if( e.dataTransfer.files.length != 1 ) {
      document.getElementsByTagName('p')[0].innerHTML = 'FAIL - file was not attached to data store';
      e.preventDefault();
    }
  };
};
    </script>
  </head>
  <body>
    <div>This test only applies to platforms where dropping a file onto a folder in the system's file manager copies/moves the file to that folder.</div>
    <ol>
      <li>Open an empty folder in your system's file manager.</li>
      <li>Select a non-empty file on your computer using the following input: <input type="file"></li>
      <li>Drag the orange square onto the folder in your system's file manager, and release it:<br><span draggable="true"></span></li>
      <li>Pass if the file is copied to the folder.</li>
    </ol>
    <p></p>
    <noscript><p>Enable JavaScript and reload</p></noscript>
  </body>
</html>