summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/editing/dnd/datastore/055.html
blob: ac2e64ed354b664008595b650c48944d31f403bb (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
<!doctype html>
<html>
  <head>
    <title>text/uri-list conversion</title>
    <style type="text/css">
div { height: 100px; width: 100px; background: orange; }
    </style>
    <script type="text/javascript">
window.onload = function () {
  var drag = document.getElementsByTagName('div')[0], fails = [];
  drag.ondragstart = function (e) {
    e.dataTransfer.setData('url','http://example.com/');
    if( !e.dataTransfer.getData('url') ) {
      document.getElementsByTagName('p')[0].innerHTML = "FAIL - getData('url') returned nothing";
    } else if( e.dataTransfer.getData('url') != e.dataTransfer.getData('text/uri-list') ) {
      document.getElementsByTagName('p')[0].innerHTML = 'FAIL - text/uri-list is not the same as url';
    } else {

      e.dataTransfer.setData('url','#foo\r\n http://example.com/#bar \r\n http://example.org/');
      if( e.dataTransfer.getData('url') != 'http://example.com/#bar' ) {
        document.getElementsByTagName('p')[0].innerHTML = 'FAIL - only the first URL should be returned - "'+e.dataTransfer.getData('url')+'"';
      } else if( e.dataTransfer.getData('text/uri-list') != '#foo\r\n http://example.com/#bar \r\n http://example.org/' ) {
        document.getElementsByTagName('p')[0].innerHTML = 'FAIL - text/uri-list should return the full data';
      } else {

        e.dataTransfer.setData('url',' ');
        if( e.dataTransfer.getData('url') ) {
          document.getElementsByTagName('p')[0].innerHTML = 'FAIL - space was not a valid URL so an empty string should have been returned';
        } else {
          document.getElementsByTagName('p')[0].innerHTML = 'PASS';
        }

      }

    }
    e.preventDefault();
  };
};
    </script>
  </head>
  <body>
    <div draggable="true"></div>
    <p>Attempt to drag the orange square.</p>
    <noscript><p>Enable JavaScript and reload</p></noscript>
  </body>
</html>