summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/editing/dnd/the-datatransferitem-interface/getAsString-manual.html
blob: c328f0031b8e04cb7494e3e97516eb92787eb68c (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
<!DOCTYPE html>
<meta charset="utf-8">
<title>DataTransferItem Test: getAsString()</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<p><input type="text" value="dragcharacters" style="border:2px blue solid; width:200px; height: 100px;"/></p>
<p><input id="container" type="text" style="border:2px green solid; width:200px; height: 100px;"/></p>

<p>Select all characters in blue box and drag to green box then drop on the green box</p>

<script>

setup({explicit_done : true, explicit_timeout : true});

let container = document.getElementById("container");

on_event(container, "drop", evt => {
  let item = evt.dataTransfer.items[0];

  test(() => {
    let file1 = item.getAsFile();
    assert_equals(file1, null);
  }, "Check if DataTransferItem.getAsFile return null if drag data item kind is not File");

  let data;
  item.getAsString(str => {
    data = str;
  });
  setTimeout(() => {
    test(() => {
      assert_equals(data, "dragcharacters");
    }, "Check if DataTransferItem.getAsString return the dragged string");
    done();
  }, 0);
});

</script>