4 <script src=
"../../resources/js-test.js"></script>
7 border:
1px solid black;
12 border:
1px solid black;
20 function dragstart(event
)
22 testItem
= event
.dataTransfer
.items
.add(testFile
);
23 shouldBeEqualToString('testItem.kind', 'file');
24 shouldBeEqualToString('testItem.type', 'text/plain');
27 function dragenter(event
)
29 event
.preventDefault();
32 function dragover(event
)
34 event
.preventDefault();
40 testItems
= event
.dataTransfer
.items
;
41 shouldBe('testItems.length', '1');
42 shouldBeNull('testItems.add(testFile)'); // Read-only.
43 shouldBe('testItems.length', '1');
44 shouldBeEqualToString('testItems[0].kind', 'file');
45 shouldBeEqualToString('testItems[0].type', 'text/plain');
51 if (!window
.testRunner
)
54 // First, we need to generate a File object to use for our tests.
55 eventSender
.beginDragWithFiles(['test.txt']);
56 var inputElement
= document
.getElementsByTagName('input')[0];
57 eventSender
.mouseMoveTo(inputElement
.offsetLeft
+ inputElement
.offsetWidth
/ 2,
58 inputElement
.offsetTop
+ inputElement
.offsetHeight
/ 2);
59 eventSender
.mouseUp();
60 testFile
= inputElement
.files
[0];
62 // Now run the actual test.
63 var dragElement
= document
.getElementById('drag');
64 eventSender
.mouseMoveTo(dragElement
.offsetLeft
+ dragElement
.offsetWidth
/ 2,
65 dragElement
.offsetTop
+ dragElement
.offsetHeight
/ 2);
66 eventSender
.mouseDown();
67 eventSender
.leapForward(100);
68 var dropElement
= document
.getElementById('drop');
69 eventSender
.mouseMoveTo(dropElement
.offsetLeft
+ dropElement
.offsetWidth
/ 2,
70 dropElement
.offsetTop
+ dropElement
.offsetHeight
/ 2);
71 eventSender
.mouseUp();
77 <p>To manually test, select a text file for the file input element, and then drag 'Drag Me' to 'Drop Here' and drop.
78 <input type=
"file"></input>
79 <div draggable=
"true" id=
"drag" ondragstart=
"dragstart(event)">Drag Me
</div>
80 <div id=
"drop" ondragenter=
"dragenter(event)" ondragover=
"dragover(event)" ondrop=
"drop(event)">Drop Here
</div>
82 <div id=
"console"></div>
84 description("Tests DataTransferItemList file handling");
85 window
.jsTestIsAsync
= true;
87 window
.onload
= runTest
;